<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>A.J.</title>
	<atom:link href="http://ayax79.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ayax79.wordpress.com</link>
	<description>Someday somehow someone is going to steal your carbon.</description>
	<lastBuildDate>Mon, 26 Sep 2011 18:28:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ayax79.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>A.J.</title>
		<link>http://ayax79.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ayax79.wordpress.com/osd.xml" title="A.J." />
	<atom:link rel='hub' href='http://ayax79.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Apparently Chrome doesn&#8217;t like HTML files</title>
		<link>http://ayax79.wordpress.com/2009/11/11/apparently-chrome-doesnt-like-html-files/</link>
		<comments>http://ayax79.wordpress.com/2009/11/11/apparently-chrome-doesnt-like-html-files/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 19:20:48 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=71</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=71&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-75" title="Screen shot 2009-11-11 at 11.14.37 AM" src="http://ayax79.files.wordpress.com/2009/11/screen-shot-2009-11-11-at-11-14-37-am3.png?w=700&#038;h=372" alt="Screen shot 2009-11-11 at 11.14.37 AM" width="700" height="372" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=71&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/11/11/apparently-chrome-doesnt-like-html-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>

		<media:content url="http://ayax79.files.wordpress.com/2009/11/screen-shot-2009-11-11-at-11-14-37-am3.png" medium="image">
			<media:title type="html">Screen shot 2009-11-11 at 11.14.37 AM</media:title>
		</media:content>
	</item>
		<item>
		<title>Speaking at an SAO event Oct. 15th.</title>
		<link>http://ayax79.wordpress.com/2009/10/10/speaking-at-an-sao-event-oct-15th/</link>
		<comments>http://ayax79.wordpress.com/2009/10/10/speaking-at-an-sao-event-oct-15th/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 23:52:19 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=68</guid>
		<description><![CDATA[all, I will be speaking at the Software Association of Oregon&#8217;s &#8220;An Integrated Development Tools Stack: Soup-to-Nuts Implementation in Practice&#8221; event this coming thursday if anyone is intrested. More information can be found here: http://www.sao.org/events/event_details.asp?id=71592<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=68&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>all,</p>
<p>I will be speaking at the Software Association of Oregon&#8217;s &#8220;An Integrated Development Tools Stack: Soup-to-Nuts Implementation in Practice&#8221; event this coming thursday if anyone is intrested. More information can be found here:</p>
<p><a title="http://www.sao.org/events/event_details.asp?id=71592" href="http://www.sao.org/events/event_details.asp?id=71592">http://www.sao.org/events/event_details.asp?id=71592</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=68&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/10/10/speaking-at-an-sao-event-oct-15th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Uploadify and Stripes</title>
		<link>http://ayax79.wordpress.com/2009/07/01/uploadify-and-stripes/</link>
		<comments>http://ayax79.wordpress.com/2009/07/01/uploadify-and-stripes/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 21:42:33 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[stripes]]></category>
		<category><![CDATA[uploadify]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=66</guid>
		<description><![CDATA[Uploadify is a pretty cool plugin for jquery that uses flash for a bulk uploader. The only sucky thing is the examples are for php. So I wrote one for stripes: git://github.com/ayax79/stripes-uploadify.git<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=66&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Uploadify is a pretty cool plugin for jquery that uses flash for a bulk uploader. The only sucky thing is the examples are for php.</p>
<p>So I wrote one for stripes:</p>
<p>git://github.com/ayax79/stripes-uploadify.git</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=66&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/07/01/uploadify-and-stripes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Driving Test Data with groovy + hibernate</title>
		<link>http://ayax79.wordpress.com/2009/06/18/driving-test-data-with-groovy-hibernate/</link>
		<comments>http://ayax79.wordpress.com/2009/06/18/driving-test-data-with-groovy-hibernate/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 23:55:27 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=59</guid>
		<description><![CDATA[The appfuse guys have a pretty cool setup where they have the hibernate plugin and the dbunit plugin working together to reload your dev database with each build. While this rocks I would rather populate data using my existing hibernate model. Using gmaven I tied together a script to initialize everything. In my pom I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=59&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The appfuse guys have a pretty cool setup where they have the hibernate plugin and the dbunit plugin working together to reload your dev database with each build. While this rocks I would rather populate data using my existing hibernate model. Using gmaven I tied together a script to initialize everything.</p>
<p>In my pom I have the following two plugsin configured:</p>
<pre class="brush: xml;">
&lt;plugin&gt;

&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;

&lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;

&lt;version&gt;2.2&lt;/version&gt;

&lt;configuration&gt;

&lt;components&gt;

&lt;component&gt;

&lt;name&gt;hbm2ddl&lt;/name&gt;

&lt;implementation&gt;annotationconfiguration&lt;/implementation&gt;

&lt;!--

Use 'jpaconfiguration' if you're using JPA.

&lt;implementation&gt;jpaconfiguration&lt;/implementation&gt;

--&gt;

&lt;/component&gt;

&lt;/components&gt;

&lt;componentProperties&gt;

&lt;drop&gt;true&lt;/drop&gt;

&lt;jdk5&gt;true&lt;/jdk5&gt;
&lt;propertyfile&gt;target/classes/jdbc.properties&lt;/propertyfile&gt;

&lt;skip&gt;${maven.test.skip}&lt;/skip&gt;

&lt;/componentProperties&gt;

&lt;/configuration&gt;

&lt;executions&gt;

&lt;execution&gt;
&lt;phase&gt;process-test-resources&lt;/phase&gt;

&lt;goals&gt;

&lt;goal&gt;hbm2ddl&lt;/goal&gt;

&lt;/goals&gt;

&lt;/execution&gt;

&lt;/executions&gt;

&lt;dependencies&gt;

&lt;dependency&gt;

&lt;groupId&gt;${jdbc.groupId}&lt;/groupId&gt;

&lt;artifactId&gt;${jdbc.artifactId}&lt;/artifactId&gt;

&lt;version&gt;${jdbc.version}&lt;/version&gt;

&lt;/dependency&gt;

&lt;/dependencies&gt;

&lt;/plugin&gt;
&lt;plugin&gt;

                &lt;groupId&gt;org.codehaus.groovy.maven&lt;/groupId&gt;

                &lt;artifactId&gt;gmaven-plugin&lt;/artifactId&gt;

                &lt;version&gt;1.0-rc-5&lt;/version&gt;

                &lt;configuration&gt;

                    &lt;source&gt;${pom.basedir}/src/test/resources/sampledata.groovy&lt;/source&gt;

                &lt;/configuration&gt;

                &lt;executions&gt;

                    &lt;execution&gt;

                        &lt;id&gt;populate-db&lt;/id&gt;
&lt;phase&gt;test-compile&lt;/phase&gt;

                        &lt;goals&gt;

                            &lt;goal&gt;execute&lt;/goal&gt;

                        &lt;/goals&gt;

                    &lt;/execution&gt;

                &lt;/executions&gt;

                &lt;dependencies&gt;

                    &lt;dependency&gt;

                        &lt;groupId&gt;${jdbc.groupId}&lt;/groupId&gt;

                        &lt;artifactId&gt;${jdbc.artifactId}&lt;/artifactId&gt;

                        &lt;version&gt;${jdbc.version}&lt;/version&gt;

                    &lt;/dependency&gt;

                &lt;/dependencies&gt;

            &lt;/plugin&gt;
</pre>
<p>Then I wrote the following script (that is referenced in the plugin above):</p>
<pre class="brush: java;">

// initializes hibernate

this.sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory()

this.call = 0

class SaveDelegate {

  Session session

  DateTime now

  def save(o) {

    session.saveOrUpdate(o)

    session.flush()

    return o;

  }

// Used to save the objects.

def save(o) {

  def con = DriverManager.getConnection(project.properties['jdbc.url'], project.properties['jdbc.username'], project.properties['jdbc.password'])

  def session = this.sessionFactory.openSession(con)

  try {

    println call++

    if (o instanceof Closure) {

      return o.call(new SaveDelegate(session: session, now: this.now))

    }

    else {

      return new SaveDelegate(session: session, now: this.now).save(o)

    }

  } catch (e) {

    System.err.println e.message

    return null;

  } finally {

    session.close()

    con.close()

  }

}

try {

// The save function above lets me handle objects in different ways:

// just save an instance

save new Person(name: 'Issac Brock')

// save with a reference

def f = save(new Person(name:'Jimmy Paige'))

// and finally with a closure

def f = save { s -&gt;

   def f = new Person(name: &quot;Scott Weiland&quot;)

... do other stuff

  return s.save f

}

} finally {

//cleanup

this.sessionFactory.close()

}

}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=59&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/06/18/driving-test-data-with-groovy-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>JMock Map Matcher Example</title>
		<link>http://ayax79.wordpress.com/2009/02/19/jmock-map-matcher-example/</link>
		<comments>http://ayax79.wordpress.com/2009/02/19/jmock-map-matcher-example/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 00:41:59 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=48</guid>
		<description><![CDATA[Quick example of how to use jmock matchers with maps.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=48&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Quick example of how to use jmock matchers with maps.</p>
<pre class="brush: java;">
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

// Static imports for the IsMapContaing matchers
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.collection.IsMapContaining.hasKey;

import org.hamcrest.collection.IsMapContaining;
import static org.hamcrest.core.AllOf.allOf;
import org.hamcrest.core.AllOf;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Map;
import java.util.HashMap;

@RunWith(JMock.class)
public class DefaultReportDaoUnitTest
{

    Mockery mockery = new JUnit4Mockery();

    @Test
    public void testFoo() {

        final MyStuff mine = mockery.mock(MyStuff.class, &quot;mine&quot;);

        mockery.checking(new Expectations()
        {{

            // I usually seperate this from being inline
            // so that I can get the generic type right easier
            Matcher&lt;Map&lt;String, ?&gt;&gt; mapMatcher =
                AllOf.&lt;Map&lt;String, ?&gt;&gt;allOf(
                        hasEntry(&quot;foo&quot;, &quot;one&quot;),
                        hasEntry(&quot;bar&quot;, &quot;two&quot;),
                        hasKey(&quot;baz&quot;)
                );        

            // Use the map mapmatcher we defined
            // expect one call of
            oneOf(mine).doSomething(with(mapMatcher));                                                       
        }};

        Map&lt;String,String&gt; map = new HashMap&lt;String,String&gt;(3);
        map.put(&quot;foo&quot;, &quot;one&quot;);
        map.put(&quot;bar&quot;, &quot;two&quot;);
        map.put(&quot;baz&quot;, &quot;three&quot;);

        mine.doSometing(map);                

    }        

}       
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=48&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/02/19/jmock-map-matcher-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Spring MVC and CXF play well together</title>
		<link>http://ayax79.wordpress.com/2009/02/19/making-spring-mvc-and-cxf-play-well-together/</link>
		<comments>http://ayax79.wordpress.com/2009/02/19/making-spring-mvc-and-cxf-play-well-together/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 23:32:28 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring_mvc]]></category>
		<category><![CDATA[xfire]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=43</guid>
		<description><![CDATA[I have found the spring mvc and CXF really don&#8217;t play very well together. When using spring MVC is you are pretty much stuck using the spring DispatcherServlet which for some odd reason doesn&#8217;t well with the spring ContextLoaderListener and wants to initialize the config files itself. The problem with this that if you use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=43&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have found the spring mvc and CXF really don&#8217;t play very well together. When using spring MVC is you are pretty much stuck using the spring DispatcherServlet which for some odd reason doesn&#8217;t well with the spring ContextLoaderListener and wants to initialize the config files itself.</p>
<p>The problem with this that if you use the DispatcherServlet to initialize the files then the CXFServlet isn&#8217;t able to find the context while it is initializing.</p>
<p>The only way I was able to get this to work out of the box was to list my config files in both places</p>
<pre class="brush: xml;">
&lt;!-- inside the web.xml --&gt;
&lt;!-- don't do this, duplicates bean instances --&gt;

&lt;context-param&gt;
&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
&lt;param-value&gt;/WEB-INF/myconfig.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;spring&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
        &lt;description&gt;Spring Configuration Files&lt;/description&gt;
&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
&lt;param-value&gt;
            /WEB-INF/myconfig.xml
        &lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
&lt;/servlet&gt;
</pre>
<p>The problem is that it will duplicate all your bean instances.</p>
<p>My solution is to just create a spring controller that handles the CXF requests. This was relatively easy to do using CXFServlet and AbstractCXFServlet as examples.</p>
<p>The benefit of doing this is that CXFController we create can be directly initialized with the ApplicationContext that it is created in.</p>
<pre class="brush: java;">
package com.foo;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.BusException;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.servlet.ServletContextResourceResolver;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.util.Enumeration;

public class CXFController implements Controller, ApplicationContextAware
{

    private static final Log log = LogFactory.getLog(CXFController.class);

    protected Bus bus;
    protected ServletTransportFactory servletTransportFactory;
    protected ServletController controller;
    protected WebApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
    {
        this.applicationContext = (WebApplicationContext) applicationContext;
    }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        try {
            BusFactory.setThreadDefaultBus(bus);
            controller.invoke(request, response);
        }
        catch (Exception e) {
            log.error(e.getMessage(),e);
            throw e;
        }
        finally {
            BusFactory.setThreadDefaultBus(null);
        }
        return null;
    }

    public void init()
    {
        bus = new SpringBusFactory(applicationContext).createBus();

        ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
        resourceManager.addResourceResolver(new ServletContextResourceResolver(
                applicationContext.getServletContext()));

        replaceDestinationFactory();

        // Set up the ServletController
        controller = new ServletController(servletTransportFactory,
                SERVLET_CONFIG,
                applicationContext.getServletContext(),
                bus);
    }

    public void destroy() {
        bus.shutdown(true);
    }

    protected void replaceDestinationFactory()
    {

        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
        try
        {
            DestinationFactory df = dfm
                    .getDestinationFactory(&quot;http://cxf.apache.org/transports/http/configuration&quot;);
            if (df instanceof ServletTransportFactory)
            {
                servletTransportFactory = (ServletTransportFactory) df;
                log.info(&quot;DESTIONFACTORY_ALREADY_REGISTERED&quot;);
                return;
            }
        }
        catch (BusException e)
        {
            // why are we throwing a busexception if the DF isn't found?
        }

        DestinationFactory factory = createServletTransportFactory();

        for (String s : factory.getTransportIds())
        {
            registerTransport(factory, s);
        }
        log.info(&quot;REPLACED_HTTP_DESTIONFACTORY&quot;);
    }

    private void registerTransport(DestinationFactory factory, String namespace) {
        bus.getExtension(DestinationFactoryManager.class).registerDestinationFactory(namespace, factory);
    }

    protected DestinationFactory createServletTransportFactory() {
        if (servletTransportFactory == null) {
            servletTransportFactory = new ServletTransportFactory(bus);
        }
        return servletTransportFactory;
    }

    /**
     * Annoying hack...
     *
     * The ServletController class uses the servlet config to get other init parameters. This
     * mostly just prevents ServletController from throwing NullPointerExceptions
     *
     * We don't care about any of them but here is teh list if we decide we do:
     * hide-service-list-page
     * disable-address-updates
     * base-address
     * service-list-stylesheet
     */
    public static ServletConfig SERVLET_CONFIG = new ServletConfig()
    {

        public String getServletName()
        {
            return null;
        }

        public ServletContext getServletContext()
        {
            return null;
        }

        public String getInitParameter(String name)
        {
            return null;
        }

        public Enumeration getInitParameterNames()
        {
            return null;
        }
    };

}
</pre>
<p>There are three caveats to the examples above:<br />
1. In CXFServlet it uses the ServletConfig to find specific init parameters, this can be done still with a little bit of effort by passing them in through the spring config and then use the SERVLET_CONFIG instance of ServletConfig in the example above to provide the values to the ServletController instance.</p>
<p>2. I don&#8217;t need the multiple cxf bus support so I didn&#8217;t port it over.</p>
<p>3. I didn&#8217;t add reloading support to my controller.</p>
<p>Finally you just need to configure spring to use this new controller:</p>
<pre class="brush: xml;">
&lt;bean name=&quot;cxfController&quot; class=&quot;com.foo.CXFController&quot;
          init-method=&quot;init&quot;
          destroy-method=&quot;destroy&quot;
          lazy-init=&quot;true&quot;/&gt;

    &lt;bean id=&quot;beanMappings&quot;
          class=&quot;org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping&quot;
          p:order=&quot;0&quot; /&gt;

    &lt;bean id=&quot;urlMappings&quot;
          class=&quot;org.springframework.web.servlet.handler.SimpleUrlHandlerMapping&quot;
          p:order=&quot;1&quot;&gt;
&lt;property name=&quot;urlMap&quot;&gt;
            &lt;util:map&gt;
                &lt;entry key=&quot;/cxf*/**&quot; value-ref=&quot;cxfController&quot;/&gt;
            &lt;/util:map&gt;
        &lt;/property&gt;
    &lt;/bean&gt;
</pre>
<p>It is very important to note that the cxfController is lazy initialized. This allows all services to be loaded before the CXFController does. This could probably also be done by making the CXFController an application listener and waiting until the spring context was fully initialized before initializing, but it was quicker to just make it lazy initialized <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=43&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/02/19/making-spring-mvc-and-cxf-play-well-together/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Intellij IDEA 8.1 is out!</title>
		<link>http://ayax79.wordpress.com/2009/02/12/intellij-81-is-out/</link>
		<comments>http://ayax79.wordpress.com/2009/02/12/intellij-81-is-out/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 22:07:18 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[jive]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/2009/02/12/intellij-81-is-out/</guid>
		<description><![CDATA[http://jetbrains.com If you have trouble with it working, try removing your installed extra plugins. (Under ~/Library/Application Support/IntelliJIDEA80 on the mac)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=40&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://jetbrains.com">http://jetbrains.com</a></p>
<p>If you have trouble with it working, try removing your installed extra plugins.<br />
(Under ~/Library/Application Support/IntelliJIDEA80 on the mac)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=40&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/02/12/intellij-81-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Using custom hessian Serializers with Spring</title>
		<link>http://ayax79.wordpress.com/2009/02/12/using-custom-hessian-serializers-with-spring/</link>
		<comments>http://ayax79.wordpress.com/2009/02/12/using-custom-hessian-serializers-with-spring/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 16:20:00 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[hessian]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=36</guid>
		<description><![CDATA[In my last post I showed an example of a custom hessian serializer and deserializer. In order to make this all work with spring some steps need to be performed. Normally with hessian you add your custom SerializerFactory to the main hessian SerializerFactory via the addFactory method. This is particularly spring friendly. You will need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=36&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last post I showed an example of a custom hessian serializer and deserializer. In order to make this all work with spring some steps need to be performed.</p>
<p>Normally with hessian you add your custom SerializerFactory to the main hessian SerializerFactory via the addFactory method. This is particularly spring friendly. You will need to create a subclass of SerializerFactory like the following:</p>
<pre class="brush: java;">
package com.foo;

import com.caucho.hessian.io.SerializerFactory;
import com.caucho.hessian.io.AbstractSerializerFactory;

import java.util.List;

public class SpringExtensibleSerializerFactory extends SerializerFactory
{

    public void setSerializerFactories(List&lt;AbstractSerializerFactory&gt; factories) {
        for (AbstractSerializerFactory factory : factories)
        {
            addFactory(factory);
        }
    }

}
</pre>
<p>This will allow you to add a list of custom SerializerFactory to the main hessian SerializerFactory. This SerializerFactory will need to be setup on both the client and server.</p>
<pre class="brush: xml;">
&lt;bean id=&quot;hessianSerializerFactory&quot;
          class=&quot;com.foo.SpringExtensibleSerializerFactory&quot;&gt;
&lt;property name=&quot;serializerFactories&quot;&gt;
        &lt;util:list&gt;
             &lt;bean class=&quot;com.foo.BigIntegerSerializerFactory&quot;/&gt;
        &lt;/util:list&gt;
    &lt;/property&gt;
 &lt;/bean&gt;
</pre>
<p>Next on the server side I create an abstract hessian exporter bean.</p>
<pre class="brush: xml;">
&lt;bean id=&quot;baseHessianService&quot; class=&quot;org.springframework.remoting.caucho.HessianServiceExporter&quot; abstract=&quot;true&quot;&gt;
&lt;property name=&quot;serializerFactory&quot; ref=&quot;hessianSerializerFactory&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>Services can then be exposed simply by extended the baseHessianService</p>
<pre class="brush: xml;">
&lt;bean id=&quot;myHessianService&quot; parent=&quot;baseHessianProxyFactory&quot;&gt;
&lt;property name=&quot;serviceUrl&quot;
            value=&quot;http://foo.com/hessian/MyHessianService&quot; /&gt;
&lt;property name=&quot;serviceInterface&quot;
            value=&quot;com.foo.MyHessianService&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>On the client side create an abstract bean for HessianProxyFactoryBean with an instance of the hessianSerializerFactory described above.</p>
<pre class="brush: xml;">
&lt;bean id=&quot;baseHessianProxyFactory&quot; class=&quot;org.springframework.remoting.caucho.HessianProxyFactoryBean&quot;
          abstract=&quot;true&quot; &gt;
&lt;property name=&quot;serializerFactory&quot; ref=&quot;hessianSerializerFactory&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>Services can then be consumed by extending this abstract bean</p>
<pre class="brush: xml;">
&lt;bean id=&quot;myHessianServiceProxy&quot; parent=&quot;baseHessianProxyFactory&quot;&gt;
&lt;property name=&quot;serviceUrl&quot;
            value=&quot;http://foo.com/hessian/MyHessianService&quot; /&gt;
&lt;property name=&quot;serviceInterface&quot;
            value=&quot;com.foo.MyHessianService&quot; /&gt;
&lt;/bean&gt;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=36&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/02/12/using-custom-hessian-serializers-with-spring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>BigInteger and hessian.</title>
		<link>http://ayax79.wordpress.com/2009/02/11/big-integers-and-hessian/</link>
		<comments>http://ayax79.wordpress.com/2009/02/11/big-integers-and-hessian/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:56:43 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[caucho]]></category>
		<category><![CDATA[hessian]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/?p=9</guid>
		<description><![CDATA[Out of the box hessian does not have support for java.math.BigInteger. It easy to add custom hessian serializers to hessian to extend it to handle cases like these. The deserializer: The serializer: Next you will need a serializer factory for the BigInteger Serializer/Deserializer Finally add this to the main via the SerializerFactory#addFactory method. In the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=9&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Out of the box hessian does not have support for java.math.BigInteger.<br />
It easy to add custom hessian serializers to hessian to extend it to handle cases like these.</p>
<p>The deserializer:</p>
<pre class="brush: java;">

package com.foo.hessian;

import com.caucho.hessian.io.AbstractDeserializer;
import com.caucho.hessian.io.AbstractHessianInput;

import java.io.IOException;
import java.math.BigInteger;

public class BigIntegerDeSerializer extends AbstractDeserializer
{

    public Class getType()
    {
        return BigInteger.class;
    }

    public Object readMap(AbstractHessianInput in)
            throws IOException
    {
        int ref = in.addRef(null);

        String initValue = null;

        while (!in.isEnd())
        {
            String key = in.readString();

            if (key.equals(&quot;value&quot;))
                initValue = in.readString();
            else
                in.readString();
        }

        in.readMapEnd();

        Object value = new BigInteger(initValue);

        in.setRef(ref, value);

        return value;
    }

    public Object readObject(AbstractHessianInput in, String[] fieldNames)
            throws IOException
    {
        int ref = in.addRef(null);

        String initValue = null;

        for (String key : fieldNames)
        {
            if (key.equals(&quot;value&quot;))
                initValue = in.readString();
            else
                in.readObject();
        }

        Object value = new BigInteger(initValue);

        in.setRef(ref, value);

        return value;
    }

}
</pre>
<p>The serializer:</p>
<pre class="brush: java;">
package com.foo.hessian;

import com.caucho.hessian.io.AbstractSerializer;
import com.caucho.hessian.io.AbstractHessianOutput;

import java.io.IOException;
import java.math.BigInteger;

public class BigIntegerSerializer extends AbstractSerializer
{
    public void writeObject(Object obj, AbstractHessianOutput out) throws IOException
    {

        if (obj == null)
            out.writeNull();
        else
        {
            Class cl = obj.getClass();

            if (out.addRef(obj))
                return;

            int ref = out.writeObjectBegin(cl.getName());

            BigInteger bi = (BigInteger) obj;

            if (ref &lt; -1)
            {
                out.writeString(&quot;value&quot;);
                out.writeString(bi.toString());
                out.writeMapEnd();
            }
            else
            {
                if (ref == -1)
                {
                    out.writeInt(1);
                    out.writeString(&quot;value&quot;);
                    out.writeObjectBegin(cl.getName());
                }

                out.writeString(bi.toString());
            }
        }
    }
}
</pre>
<p>Next you will need a serializer factory for the BigInteger Serializer/Deserializer</p>
<pre class="brush: java;">
public class BigIntegerSerializerFactory extends AbstractSerializerFactory
{
    public Serializer getSerializer(Class cl) throws HessianProtocolException
    {
        if (BigInteger.class.isAssignableFrom(cl)) {
            return new BigIntegerSerializer();
        }
        return null;
    }

    public Deserializer getDeserializer(Class cl) throws HessianProtocolException
    {
        if (BigInteger.class.isAssignableFrom(cl)) {
            return new BigIntegerDeSerializer();
        }
        return null;
    }
}
</pre>
<p>Finally add this to the main via the SerializerFactory#addFactory method.</p>
<p>In the next post I will show how to tie this all into spring.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=9&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2009/02/11/big-integers-and-hessian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring configuration of DWR.</title>
		<link>http://ayax79.wordpress.com/2007/12/04/spring-configuration-of-dwr/</link>
		<comments>http://ayax79.wordpress.com/2007/12/04/spring-configuration-of-dwr/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 17:24:51 +0000</pubDate>
		<dc:creator>AJ</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[dwr]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ayax79.wordpress.com/2007/12/04/spring-configuration-of-dwr/</guid>
		<description><![CDATA[I have found there really aren&#8217;t any great guides for getting DWR configured with spring. Here is my experiences. Prerequisites: Assuming some previous knowledge of DWR and spring. Spring is configured and working. DWR has been added the WEB-INF/lib. 1. Add DWR to the web.xml Instead of using the DwrServlet, make sure you use the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=7&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have found there really aren&#8217;t any great guides for getting DWR configured with spring. Here is my experiences.<br />
Prerequisites:</p>
<ul>
<li>Assuming some previous knowledge of DWR and spring.</li>
<li>Spring is configured and working.</li>
<li>DWR has been added the WEB-INF/lib.</li>
</ul>
<h4>1. Add DWR to the web.xml</h4>
<p>Instead of using the DwrServlet, make sure you use the SpringDwrServlet:</p>
<pre class="brush: xml;">
&lt;servlet&gt;
    &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
    &lt;display-name&gt;DWR Servlet&lt;/display-name&gt;

        &lt;description&gt;Direct Web Remoter Servlet&lt;/description&gt;
        &lt;servlet-class&gt;org.directwebremoting.spring.DwrSpringServlet&lt;/servlet-class&gt;
        &lt;init-param&gt;
&lt;param-name&gt;logLevel&lt;/param-name&gt;
&lt;param-value&gt;INFO&lt;/param-value&gt;
        &lt;/init-param&gt;
        &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
    &lt;/servlet&gt;&lt;/tt&gt;

&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
       &lt;url-pattern&gt;/dwr/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;&lt;
</pre>
<h4>2. Next, add the dwr namespace and schema to your spring configuration file:</h4>
<p>The namespace is xmlns:dwr=&#8221;http://www.directwebremoting.org/schema/spring-dwr&#8221;<br />
The schemaLocation is http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd</p>
<pre class="brush: xml;">
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
       xmlns:util=&quot;http://www.springframework.org/schema/util&quot;
       xmlns:dwr=&quot;http://www.directwebremoting.org/schema/spring-dwr&quot;
       xsi:schemaLocation=&quot;

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd

http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd&quot;

       default-autowire=&quot;no&quot; default-lazy-init=&quot;false&quot; default-init-method=&quot;init&quot; default-destroy-method=&quot;destroy&quot;&gt;&lt;/tt&gt;

&lt;/beans&gt;
</pre>
<h4><strong>3. Configure Spring creators.</strong></h4>
<p>There are two options for doing this. You can directly expose spring beans:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;dwrWatchesBean&quot; class=&quot;com.jivesoftware.community.action.WatchesAction&quot; &gt;

    &lt;dwr:remote javascript=&quot;Watches&quot; /&gt;
&lt;property name=&quot;communityManagerImpl&quot; ref=&quot;communityManagerImpl&quot; /&gt;
&lt;property name=&quot;forumManagerImpl&quot; ref=&quot;forumManagerImpl&quot; /&gt;
&lt;property name=&quot;watchManagerImpl&quot; ref=&quot;watchManagerImpl&quot; /&gt;
&lt;property name=&quot;documentManagerImpl&quot; ref=&quot;documentManagerImpl&quot; /&gt;
&lt;property name=&quot;blogManagerImpl&quot; ref=&quot;blogManagerImpl&quot; /&gt;
&lt;property name=&quot;userManagerImpl&quot; ref=&quot;userManagerImpl&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>The dwr:remote element is the element that will expose the bean to dwr. In my opinion this is the best approach as it allows you to wire you dependencies like any other spring object.</p>
<p>Secondly you can configure them in a dwr:configuration much in the same as the standard dwr.xml file works:</p>
<pre class="brush: xml;">
&lt;dwr:configuration&gt;
    &lt;dwr:create type=&quot;new&quot; javascript=&quot;Watches&quot;     class=&quot;com.jivesoftware.community.action.WatchesAction&quot; /&gt;
&lt;/dwr:configuration&gt;
</pre>
<h4>4. Configure spring convertors</h4>
<p>The spring configurators must be configured inside of a dwr:configuration element in spring.</p>
<pre class="brush: xml;">
&lt;dwr:configuration&gt;
    &lt;dwr:convert type=&quot;bean&quot; class=&quot;com.jivesoftware.community.Watch&quot; /&gt;
&lt;/dwr:configuration&gt;
</pre>
<h4>5. Other important elements</h4>
<p><strong>dwr:include</strong> : Used to include specific methods. Can be used with dwr:convert, dwr:create, or dwr:remote element<br />
<strong>dwr:exclude</strong> : Used to exclude specific methods. Can be used with dwr:convert, dwr:create, or dwr:remote element<br />
<strong>dwr:init </strong>: Optional element that will allow you to specify custom creator types and converter types.<br />
<strong>dwr:converter </strong>: Specifies a custom converter type, must be used within dwr:init.<br />
<strong>dwr:create</strong> : Specifies a custom creator type, must be used within a dwr:init.<br />
<strong>dwr:signature</strong> : Used to specify signatures much like the like element in the standard dwr.xml.<br />
<strong><br />
</strong></p>
<h4>6. Full Example</h4>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
       xmlns:util=&quot;http://www.springframework.org/schema/util&quot;
       xmlns:dwr=&quot;http://www.directwebremoting.org/schema/spring-dwr&quot;
       xsi:schemaLocation=&quot;
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd&quot;
       default-autowire=&quot;no&quot; default-lazy-init=&quot;false&quot; default-init-method=&quot;init&quot; default-destroy-method=&quot;destroy&quot;&gt;&lt;/tt&gt;

    &lt;bean id=&quot;dwrWatchesBean&quot; class=&quot;com.jivesoftware.community.action.WatchesAction&quot; &gt;

        &lt;dwr:remote javascript=&quot;Watches&quot; /&gt;
&lt;property name=&quot;communityManagerImpl&quot; ref=&quot;communityManagerImpl&quot; /&gt;
&lt;property name=&quot;forumManagerImpl&quot; ref=&quot;forumManagerImpl&quot; /&gt;
&lt;property name=&quot;watchManagerImpl&quot; ref=&quot;watchManagerImpl&quot; /&gt;
&lt;property name=&quot;documentManagerImpl&quot; ref=&quot;documentManagerImpl&quot; /&gt;
&lt;property name=&quot;blogManagerImpl&quot; ref=&quot;blogManagerImpl&quot; /&gt;
&lt;property name=&quot;userManagerImpl&quot; ref=&quot;userManagerImpl&quot; /&gt;
         &lt;/bean&gt;

        &lt;dwr:configuration&gt;
            &lt;dwr:convert class=&quot;com.jivesoftware.community.DraftImpl&quot; type=&quot;bean&quot; /&gt;
        &lt;dwr:create type=&quot;new&quot; javascript=&quot;ImagePicker&quot; class=&quot;com.jivesoftware.community.action.ImagePicker&quot; &gt;
            &lt;dwr:include method=&quot;getImageByName&quot; /&gt;
            &lt;dwr:include method=&quot;getImageDetailsByName&quot; /&gt;
            &lt;dwr:include method=&quot;getImageDetailsByURL&quot; /&gt;
            &lt;dwr:include method=&quot;removeImage&quot; /&gt;
        &lt;/dwr:create&gt;

        &lt;dwr:convert class=&quot;com.jivesoftware.base.User&quot; type=&quot;bean&quot; &gt;
            &lt;dwr:include method=&quot;username&quot;/&gt;
            &lt;dwr:include method=&quot;name&quot;/&gt;
            &lt;dwr:include method=&quot;ID&quot;/&gt;
        &lt;/dwr:convert&gt;
        &lt;dwr:convert class=&quot;com.jivesoftware.community.action.LDAPGroupBean&quot; type=&quot;bean&quot; /&gt;

        &lt;dwr:signatures&gt;
           &lt;![CDATA[
          import java.util.Map;
          import com.jivesoftware.community.DraftImpl;
          DraftImpl.setProperties(Map&lt;String, String&gt; properties);
          DraftImpl.setImageIDs(List&lt;Long&gt; imageIDs);
          ]]&gt;
        &lt;/dwr:signatures&gt;

    &lt;/dwr:configuration&gt;
&lt;/beans&gt;
</pre>
<h4>CAVEATS</h4>
<ul>
<li> Do not attempt to use DwrSpringServlet with org.springframework.web.servlet.mvc.ServletWrappingController. DwrSpringServlet expects the spring context to be fully initialized before it attempts to initialize.</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ayax79.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ayax79.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayax79.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayax79.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayax79.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayax79.wordpress.com&amp;blog=1764952&amp;post=7&amp;subd=ayax79&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayax79.wordpress.com/2007/12/04/spring-configuration-of-dwr/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9d52db096b56c6490457b1cb82ed37da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayax79</media:title>
		</media:content>
	</item>
	</channel>
</rss>
