<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>nthread</title>
	<atom:link href="http://slice.nthread.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://slice.nthread.com</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 11 Jul 2009 03:22:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Agile Development Versus &#8230;</title>
		<link>http://slice.nthread.com/2009/07/agile-development-versus/</link>
		<comments>http://slice.nthread.com/2009/07/agile-development-versus/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 03:22:29 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Software Development]]></category>

		<category><![CDATA[development-process project-management]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=56</guid>
		<description><![CDATA[To get started with the basics, agile in the context of development is a family of methodologies for managing software development projects with grey boundaries.  A lot of times, when people discuss agile development vs. other development methodologies, they talk about agile as though there is just one way to do it.  I think it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>To get started with the basics, <em>agile in the context of development is a family of methodologies for managing software development projects with grey boundaries. </em> A lot of times, when people discuss agile development vs. other development methodologies, they talk about agile as though there is just one way to do it.  I think it&#8217;s because they don&#8217;t really understand the variables in a software project.</p>
<p>I think that the software development methodologies form a spectrum from the ones that require the most up front design to the least.  I see the most commonly used methodologies shaking out in this order (this isn&#8217;t meant to be all inclusive):</p>
<div style='height: 1px; border-bottom: 1px solid #666666' ></div>
<p><strong>Waterfall</strong> -</p>
<ul>
<li>requirements, design, implement, test, release</li>
</ul>
<p><strong>Mini Waterfall</strong></p>
<ul>
<li>requirements, design, implement, test, release, repeat</li>
</ul>
<p><strong>Scrum</strong></p>
<ul>
<li>add known issues and wants to feature backlog, group features into sprint (2-4 weeks development), prototype as needed, development and test, repeat</li>
</ul>
<p><strong>Extreme &amp; Microsoft Agile</strong></p>
<ul>
<li>create user story, prototype as needed, break story into developer &amp; designer tasks, implement and test task implementations, repeat</li>
</ul>
<p><strong>Cowboy Coding</strong></p>
<ul>
<li>design interfaces and write code, show it to people</li>
<li>I think the name makes is sound worse than it is.</li>
</ul>
<div style='height: 1px; border-bottom: 1px solid #666666' ></div>
<p>Most of the time, people talk about whether to use agile methodologies or more traditional waterfall approaches.  I think this misses the more common scenario at startups, where they are often using cowboy coding to get things done.  The name doesn&#8217;t make it sound all that good, I think that &#8220;cowboy&#8221; sort of refers to the fact that developers are off writing code and no one knows what the hell they are doing.</p>
<p>Agile development strategies and waterfall are designed in a way to give metrics that can help non-team members have the warm and fuzzy feeling that they know how things are progessing, and are helpful to the team to some degree as well.  I&#8217;m not trying to weigh agile techniques against waterfall, as far as I&#8217;m concerned, that ship has sailed and agile is the only way to go.  I am trying to contrast the difference between formal approaches and informal approaches.  In cowboy coding, you don&#8217;t have metrics, only a system that is hopefully taking shape.  This is hard for non-team developers to project and resource against, and it&#8217;s hard for non-team people to work with.</p>
<p>Basically, I see cowboy coding as being the cult of the developer, and the more formal methods as being centered around project managers and other folks.</p>
<p><strong>Think About The Great Startups</strong></p>
<p>I don&#8217;t think that Page &amp; Brin were having sprint meetings and working with product managers.  I don&#8217;t think that Fake and Butterfield from Flickr were sitting around having meetings all day long.  Zuckerberg understood the idea of Facebook when it was explained to him, took the idea for his own, and ran with it (so it is said).</p>
<p>All of these companies were probably doing their most important foundational work with cowboy coding and not that many people.  Later, they hired many more people and switched to formal development approaches to ensure that they could have developers working towards the ends sought out by the business development people, but at the start, I think they were all cowboy.</p>
<p>It&#8217;s just my alternate view on the whole agile vs. waterfall discussions that happen often.  What about agile vs. cowboy?  What about hiring good developers and just telling them to roll on the idea.  Okay, it&#8217;s hard to manage and won&#8217;t work on scale, but are you at scale yet?  At least think about it before you put in more process than makes sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/07/agile-development-versus/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tomcat on Ubuntu</title>
		<link>http://slice.nthread.com/2009/05/tomcat-on-ubuntu/</link>
		<comments>http://slice.nthread.com/2009/05/tomcat-on-ubuntu/#comments</comments>
		<pubDate>Fri, 15 May 2009 04:45:56 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=15</guid>
		<description><![CDATA[Are you trying to run Tomcat 6 on Ubuntu.
Are you seeing a stack trace that starts with:

java.lang.NoClassDefFoundError: org/springframework/core/NestedExceptionUtils
        at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
        at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)
        at java.lang.Throwable.toString(Throwable.java:343)

Go into your /etc/init.d/tomcat file and change

# Use the Java security [...]]]></description>
			<content:encoded><![CDATA[<p>Are you trying to run Tomcat 6 on Ubuntu.<br />
Are you seeing a stack trace that starts with:</p>
<pre lang='java' >
java.lang.NoClassDefFoundError: org/springframework/core/NestedExceptionUtils
        at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
        at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)
        at java.lang.Throwable.toString(Throwable.java:343)
</pre>
<p>Go into your /etc/init.d/tomcat file and change</p>
<pre lang='bash'>
# Use the Java security manager? (yes/no)
TOMCAT6_SECURITY=yes
</pre>
<p>to</p>
<pre lang='bash'>
# Use the Java security manager? (yes/no)
TOMCAT6_SECURITY=no
</pre>
<p>Don&#8217;t leave it like this, but it will fix your problem, you are having a file policy issue and will need to make additions to your security policy to allow web applications to read files.</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/tomcat-on-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Google Java App Engine</title>
		<link>http://slice.nthread.com/2009/05/google-java-app-engine/</link>
		<comments>http://slice.nthread.com/2009/05/google-java-app-engine/#comments</comments>
		<pubDate>Wed, 13 May 2009 04:45:37 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=14</guid>
		<description><![CDATA[I just started working with the Google Java App Engine.

 + It&#8217;s super easy to deploy to
 -The persistence feels really unatural.  You just create JPA objects and use their persister, no DB create scripts
 + No DB create scripts, I think I&#8217;m going to like this once I&#8217;m used to it
 - I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I just started working with the Google Java App Engine.</p>
<ul>
<li> + It&#8217;s super easy to deploy to</li>
<li> -The persistence feels really unatural.  You just create JPA objects and use their persister, no DB create scripts</li>
<li> + No DB create scripts, I think I&#8217;m going to like this once I&#8217;m used to it</li>
<li> - I&#8217;m not sure how data export and migration works</li>
</ul>
<p>Pretty neat though, you should try it out if you can still sign up for the beta.</p>
<p>You need a persistent class.</p>
<pre lang="java">
package com.nthread.babelhelp.datamodel;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class HelloGDB {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private int count;

	public HelloGDB(int count) {
		this.count = count;
	}

	public Long getId() {
		return id;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getCount() {
		return count;
	}
}
</pre>
<p>You have to use a singleton to keep your static PersistenceManagerFactory - if you try to instantiate it twice, you will find your app pretty unhappy.</p>
<pre lang="java" >
package com.nthread.babelhelp.model;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

public class Persistor {
	private static PersistenceManagerFactory pmfInstance =
		JDOHelper.getPersistenceManagerFactory("transactions-optional");

	public static PersistenceManager getManager() {
		return pmfInstance.getPersistenceManager();
	}
}
</pre>
<p>I just use these things from a Servlet, it&#8217;s pretty basic.</p>
<pre lang="java" >
package com.nthread.babelhelp.control;

import java.io.IOException;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.nthread.babelhelp.datamodel.HelloGDB;
import com.nthread.babelhelp.model.Persistor;

public class HelloWorldServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
		doRequest(req, resp);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
		doRequest(req, resp);
	}

	protected void doRequest(HttpServletRequest req, HttpServletResponse resp) {
		PersistenceManager pm = Persistor.getManager();

		String query = "select from " + HelloGDB.class.getName();
		List<HelloGDB> hellos = (List<HelloGDB>) pm.newQuery(query).execute();

		HelloGDB helloGDB = null;
		if (!hellos.isEmpty()) {
			helloGDB = hellos.get(0);
		} else {
			helloGDB = new HelloGDB(0);
		}
		helloGDB.setCount(helloGDB.getCount() + 1);
		try {
			pm.makePersistent(helloGDB);
		} finally {
			pm.close();
		}

		String str = "Current count is " + helloGDB.getCount();
		try {
			resp.getWriter().write("<html><body>" + str + "</body></html>");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/google-java-app-engine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing Unit Tests For Servlet Filters using Spring&#8217;s Mock Classes</title>
		<link>http://slice.nthread.com/2009/05/writing-unit-tests-for-servlet-filters-using-springs-mock-classes/</link>
		<comments>http://slice.nthread.com/2009/05/writing-unit-tests-for-servlet-filters-using-springs-mock-classes/#comments</comments>
		<pubDate>Wed, 13 May 2009 04:45:18 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=13</guid>
		<description><![CDATA[Unit testing is a lot easier if you don&#8217;t have to run a web container, and the spring framework includes a library of solid mock classes for testing.  There are a ton of pages out there talking about how to test Spring MVC controllers with the mock classes so I&#8217;m not going to get [...]]]></description>
			<content:encoded><![CDATA[<p>Unit testing is a lot easier if you don&#8217;t have to run a web container, and the spring framework includes a <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/index.html?org/springframework/mock/web/package-summary.html" target="_blank">library of solid mock classes</a> for testing.  There are a ton of pages out there talking about how to test Spring MVC controllers with the mock classes so I&#8217;m not going to get into that.  I will instead walk through testing a Servlet Filter.</p>
<p>The filter is a pretty lame filter called StrangeFilter.  All is does is forward requests with a parameter set.  </p>
<pre lang="JAVA">package com.nthread.sandbox;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class StrangeFilter implements Filter {

	private FilterConfig filterConfig;

	public StrangeFilter() {
		// TODO Auto-generated method stub
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain)
			throws IOException, ServletException {
		if ("okay".equals(request.getParameter(""))) {
			this.filterConfig.getServletContext()
				.getRequestDispatcher("/fail.html")
				.forward(request, response);
		} else {
			chain.doFilter(request, response);
		}
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		this.filterConfig = filterConfig;
	}

	public void destroy() {
		// TODO Auto-generated method stub
	}
}</pre>
<p>To test this filter without a web container is really pretty easy.  You need to make use of four Mock classes provided by the Spring test framework, but basically, it&#8217;s just as easy as any other unit test.  I think the code pretty much speaks for itself, so here it is.</p>
<pre lang="JAVA">package com.nthread.sandbox;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;

import java.io.IOException;

import javax.servlet.ServletException;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockFilterConfig;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

public class StrangeFilterTest {

	private StrangeFilter filter;
	private MockHttpServletRequest request;
	private MockHttpServletResponse response;
	private MockFilterChain chain;

	@Before
	public void setUp() throws Exception {
		filter = new StrangeFilter();
		filter.init(new MockFilterConfig());
		request = new MockHttpServletRequest();
		response = new MockHttpServletResponse();
		chain = new MockFilterChain();
	}

	@Test
	public void testDoFilterWithFail() throws IOException, ServletException {
		request.addParameter("failThis", "okay");
		filter.doFilter(request, response, chain);
		assertEquals("/fail.html", response.getForwardedUrl());
	}

	@Test
	public void testDoFilterWithoutFail() throws IOException, ServletException {
		filter.doFilter(request, response, chain);
		assertNull(response.getForwardedUrl());
	}

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/writing-unit-tests-for-servlet-filters-using-springs-mock-classes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Job Scheduling</title>
		<link>http://slice.nthread.com/2009/05/java-job-scheduling/</link>
		<comments>http://slice.nthread.com/2009/05/java-job-scheduling/#comments</comments>
		<pubDate>Mon, 11 May 2009 04:44:57 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=12</guid>
		<description><![CDATA[In my continued efforts to provide an opinionated view on Java architecture, I&#8217;m going to talk about scheduling frameworks and to that end, I&#8217;m only going to talk about one.
Quartz
Quartz is really the only framework that is widely supported in Java:

It has great Spring support, outlined at http://static.springframework.org/spring/docs/2.5.x/reference/scheduling.html.  This is definitely the best way [...]]]></description>
			<content:encoded><![CDATA[<p>In my continued efforts to provide an opinionated view on Java architecture, I&#8217;m going to talk about scheduling frameworks and to that end, I&#8217;m only going to talk about one.</p>
<h4><a href="http://www.opensymphony.com/quartz/" target="_blank">Quartz</a></h4>
<p>Quartz is really the only framework that is widely supported in Java:</p>
<ul>
<li>It has great Spring support, outlined at <a href="http://static.springframework.org/spring/docs/2.5.x/reference/scheduling.html">http://static.springframework.org/spring/docs/2.5.x/reference/scheduling.html</a>.  This is definitely the best way to use Quartz in most cases.</li>
<li>Quartz can be run programatically, but you have to write a tiny bit of code to do it.  There is a <a href="http://www.opensymphony.com/quartz/wikidocs/QuickStart.html" target="_blank">quick start guide</a> on the quartz site - basically, you need a properties file and a main class, so not that bad.  Still a little harder than the spring way, so not desirable.</li>
<li>It is very easy to run Quartz as a servlet - the documentation is actually contained in the <a href="http://quartz.sourceforge.net/javadoc/org/quartz/ee/servlet/QuartzInitializerServlet.html" target="_blank">Javadoc</a>.  It&#8217;s similar to the programatic method in that you need to write a properties file, but you don&#8217;t have to write a main method, and that&#8217;s a good thing.</li>
</ul>
<p>Quartz is solid, use it if you need scheduled tasks.  The Canuck&#8217;s just scored, and I&#8217;m going to watch the game now.</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/java-job-scheduling/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Testing &amp; Code Coverage</title>
		<link>http://slice.nthread.com/2009/05/java-testing-code-coverage/</link>
		<comments>http://slice.nthread.com/2009/05/java-testing-code-coverage/#comments</comments>
		<pubDate>Mon, 11 May 2009 04:44:31 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=10</guid>
		<description><![CDATA[Basic Java testing is really not that interesting, you use Junit (did I really need to include a link?), and hopefully version 4 with annotations.  Once you have started writing unit tests, you may notice that there are more things you want to test, and you should probably find out how good your tests [...]]]></description>
			<content:encoded><![CDATA[<p>Basic Java testing is really not that interesting, you use <a href="http://www.junit.org/" target="_blank">Junit </a>(did I really need to include a link?), and hopefully version 4 with annotations.  Once you have started writing unit tests, you may notice that there are more things you want to test, and you should probably find out how good your tests are.</p>
<h3>Code Coverage</h3>
<p>Code coverage reports are a great way to tell if your have written enough unit tests for your code.  Generally, your tests should cover at least 90% of your code, and once you have code coverage tools, you will probably feel compelled to reach high %s of coverage.  I looked around at a bunch of tools and tried out what I could.  There were three tools that stood out (for good reasons, <a href="http://coverlipse.sourceforge.net/index.php">coverlipse</a> killed my eclipse install, and I don&#8217;t really recommed trying it).</p>
<h4><a href="http://cobertura.sourceforge.net/" target="_blank">Cobertura</a></p>
<p><div id="attachment_34" class="wp-caption alignnone" style="width: 970px"><img class="size-full wp-image-34" title="Cobertura" src="http://www.nthread.com/wp-content/uploads/2009/05/cobertura.gif" alt="Cobertura" width="960" height="340" /><p class="wp-caption-text">Cobertura</p></div></h4>
<p>Cobertura was very easy to get running with Maven, but was a little more challenging with Ant.  Generally a really good tool but not that easy to integrate into eclipse, the UIs are the most visually appealing.</p>
<h4><a href="http://www.codecover.org/index.html" target="_blank">CodeCover</a></h4>
<h4 class="mceTemp">
<dl id="attachment_32" class="wp-caption alignnone" style="width: 912px;">
<dt class="wp-caption-dt"><img class="size-full wp-image-32" title="CodeCover Screenshot" src="http://www.nthread.com/wp-content/uploads/2009/05/untitled-1.gif" alt="CodeCover Screenshot" width="902" height="432" /></dt>
<dd class="wp-caption-dd">CodeCover Screenshot</dd>
</dl>
</h4>
<p>CodeCover was really well integrated with Eclipse and works pretty well out of the box.  Definite a plus.  I didn&#8217;t really like the mechanism for adding classes, but if I used a normal Maven project setup, that would probably be fine.  This is a good tool for local development, but the team tools are not that extensive.</p>
<h4><a href="http://www.atlassian.com/software/clover/" target="_blank">Clover</a></h4>
<p>Just for completeness, I should give the atlassian product mention.  While a good product, Atlassian (the makers of Jira) at starting to be a little too expensive.</p>
<p>Overall, I like these tools a lot and hopefully this will help you get started with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/java-testing-code-coverage/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Software Architecture Reading</title>
		<link>http://slice.nthread.com/2009/05/software-architecture-reading/</link>
		<comments>http://slice.nthread.com/2009/05/software-architecture-reading/#comments</comments>
		<pubDate>Thu, 07 May 2009 04:43:56 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=9</guid>
		<description><![CDATA[I&#8217;ve always been a big fan of the joelonsoftware blog, and in the area of software architecture, Don&#8217;t Let Architecture Astronauts Scare You and Things You Should Never Do.  Generally, if you have not read Joel&#8217;s blog or books, go through the best of in the right nav and read most of it.
 97 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a big fan of the <a href="http://joelonsoftware.com/">joelonsoftware blog</a>, and in the area of software architecture, <a href="http://joelonsoftware.com/articles/fog0000000018.html" target="_blank">Don&#8217;t Let Architecture Astronauts Scare You </a>and <a href="http://joelonsoftware.com/articles/fog0000000069.html" target="_blank">Things You Should Never Do</a>.  Generally, if you have not read Joel&#8217;s blog or books, go through the best of in the right nav and read most of it.</p>
<p> <a href="http://97-things.near-time.net/wiki/97-things-every-software-architect-should-know-the-book" target="_blank">97 Things Every Software Architect Should Know</a> has a very good list of gotcha&#8217;s and rules of thumbs for software architects.</p>
<p> The thing that got me thinking about this was <a href="http://techdistrict.kirkk.com/2009/05/06/agile-architecture/" target="_blank">Agile Architecture</a>, a good blog today about keeping architecture moving along during a project, always a good idea.</p>
<p>All of these are good reads, and it makes me think about the useless courses in software engineering I took in university where professors spent hours excitedly talking about the capability maturity model.  I guess it didn&#8217;t matter, I really didn&#8217;t know how to work through a big project in school. </p>
<ul>
<li>A key thing with any project is that the development and design be broken up into phases that are small enough to think through and get done. </li>
<li>If the tools and frameworks that you are trying to develop with are hard to use or seem like a pain to develop with, they just aren&#8217;t the right ones.  There are easy to use tools for everything out there.</li>
<li>In general, do a project the easiest way possible.  Sometimes people try to do things because they feel like they are the &#8220;right&#8221; way to do things, even though they aren&#8217;t the easiest.  These are not the right way to do things. </li>
</ul>
<p>Keep it simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/software-architecture-reading/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Web Services</title>
		<link>http://slice.nthread.com/2009/05/java-web-services/</link>
		<comments>http://slice.nthread.com/2009/05/java-web-services/#comments</comments>
		<pubDate>Thu, 07 May 2009 04:43:29 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=8</guid>
		<description><![CDATA[So I just spent a good chunk of time looking around at web service libraries for Java.  My criteria were not long:

JSON support, really SOAP wasn&#8217;t that much of a requirement, but all of the mature libraries support it.
Simple to setup and develop with
Easy to maintain services

First, I tried my old standby Apache Axis. [...]]]></description>
			<content:encoded><![CDATA[<p>So I just spent a good chunk of time looking around at web service libraries for Java.  My criteria were not long:</p>
<ul>
<li>JSON support, really SOAP wasn&#8217;t that much of a requirement, but all of the mature libraries support it.</li>
<li>Simple to setup and develop with</li>
<li>Easy to maintain services</li>
</ul>
<p>First, I tried my old standby <a href="http://ws.apache.org/axis/" target="_blank">Apache Axis</a>. </p>
<ul>
<li>I found it fairly difficult to find documentation on running Axis services in a web container.  Whatever, I got through that, it&#8217;s actually pretty easy once you find the right page.</li>
<li>Running JSON services is not that easy.  Axis default to adding namespaces to everything, but the out of the two JSON types:
<ul>
<li>Badgerfish - the formatting is just wierd, and not that great for typical Javascript development</li>
<li>Mapped - this was normal, but then really didn&#8217;t work well with namespaces</li>
</ul>
</li>
<li>All of this really lead to having to hand edit the WSDL files to get a good result with JSON services.  This really isn&#8217;t that great for maintaining.</li>
<li>Also, it just seemed like too many jars were brought in by the Axis pom file</li>
</ul>
<p>So I moved on to trying out <a href="https://jax-ws.dev.java.net/" target="_blank">JAX-WS </a>from Sun.</p>
<ul>
<li>Setting up a SOAP based web service using these libraries was a little bit tough in terms of finding good documentation, but turned out to not be that bad.</li>
<li>Building JSON with the JAX-WS was a disaster.  Neither of the libraries I could find really worked at all.
<ul>
<li><a href="https://jax-ws-commons.dev.java.net/json/" target="_blank">JAX-WS Commons JSON</a> was the first library I tried.  The basic setup was pretty easy, but it just doesn&#8217;t work well with object return types.  So a no go.</li>
<li><a href="http://code.google.com/p/jsonwebservice/">http://code.google.com/p/jsonwebservice/</a> was the second library I tried out - again, it just didn&#8217;t do it.</li>
</ul>
</li>
</ul>
<p>At this point, I was still developing on Axis and kind of resolving myself to having to maintain a WSDL file but I stumbled across <a href="https://jersey.dev.java.net/" target="_blank">Jersey</a>.  Jersey is Sun&#8217;s REST library, and while I wasn&#8217;t necessarily looking for a resty library:</p>
<ul>
<li>Jersey works!  <a href="http://www.theserverlabs.com/blog/2009/01/12/rest-web-services-with-jaxb-jax-rs-and-sun-jersey/" target="_blank">This page </a>has a good outline of what you need to do from maven to web container.</li>
<li>It&#8217;s so easy, JSON, SOAP, both super easy.  Not much config, just point your web.xml at the packages with your services.</li>
<li>The <a href="http://blogs.sun.com/naresh/entry/jersey_test_framework_makes_it" target="_blank">test framework </a>is very well thought out too, and works well with JUnit.</li>
</ul>
<p>And that&#8217;s it.  Use Jersey, and hope that Oracle likes it (so they don&#8217;t make it disapear).</p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/05/java-web-services/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScriptTemplates (JST)</title>
		<link>http://slice.nthread.com/2009/04/javascripttemplates-jst/</link>
		<comments>http://slice.nthread.com/2009/04/javascripttemplates-jst/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 00:05:15 +0000</pubDate>
		<dc:creator>steve</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://slice.nthread.com/?p=3</guid>
		<description><![CDATA[I started working with JavaScriptTemplates today after finding that jtemplates really let me down on performance on a long template (it was taking about 2.5s to load, JST topped at 200ms).
Just to give you a flavor for how it works, I’ll outline how I used it. To start, I created a JSON data file - [...]]]></description>
			<content:encoded><![CDATA[<p>I started working with JavaScriptTemplates today after finding that jtemplates really let me down on performance on a long template (it was taking about 2.5s to load, JST topped at 200ms).</p>
<p>Just to give you a flavor for how it works, I’ll outline how I used it. To start, I created a JSON data file - typically this would be fed by a web service, but for getting up and running, a file is easy.</p>
<p><em>userdata.json:</em><br />
<span style="COLOR: #339966">{  users : [<br />
    { name: "John Doe",  email: "</span><a href="mailto:john.doe@oddmill.com"><span style="COLOR: #339966">john.doe@nthread.com</span></a><span style="COLOR: #339966">"},<br />
    { name: "Jane Doe",  email: "</span><span style="COLOR: #339966">jane.doe@nthread.com</span><span style="COLOR: #339966">"}<br />
] }</span></p>
<p>Then I created a really basic web page. The page had a div where the templated HTML would be placed:</p>
<p><span style="COLOR: #339966">&lt;div id=&#8217;userlist&#8217; &gt;&lt;/div&gt;</span></p>
<p>And imported the jQuery &amp; JST scripts in the header:</p>
<p><span style="COLOR: #339966">&lt;script src=&#8221;scripts/jquery.min.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script src=&#8221;scripts/trimpath-template.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</span></p>
<p><script src="scripts/jquery.min.js" type="text/javascript"></script><script src="scripts/trimpath-template.js" type="text/javascript"></script>Next, I created the template, which needs to be placed in a textarea. All of the templating libraries I have seen use a textarea for this, probably because it is the only place on a web page where you can avoid the browser parsing the HTML into DOM elements (which leads to escaping):</p>
<pre><span style="COLOR: #339966">&lt;textarea id='userlist_template' style='display:none' &gt;
 &lt;ul&gt;
 {for user in users}
 &lt;li&gt;&lt;a href='mailto:${user.email}' &gt;${user.name}&lt;/a&gt;&lt;/li&gt;
 {/for}
&lt;/ul&gt;
&lt;/textarea&gt;</span></pre>
<p>Finally, a small piece of JST &amp; jQuery is used to load the JSON file in process it through the template:</p>
<pre><span style="color: #339966;">&lt;script type="text/javascript" &gt;
 $(document).ready(function() {
  var data = $.getJSON("users.json", null, showData);
 });
 function showData(data) {
     var userlistTemplate = TrimPath.parseDOMTemplate("userlist_template");
     $("#userlist").html(userlistTemplate.process(data));
 }
&lt;/script&gt;</span></pre>
<p>That’s really all there is to it. This prints out the fairly unexciting:</p>
<p><span style="COLOR: #339966"><span style="COLOR: #000000"><span style="FONT-WEIGHT: bold">User List</span> </span></span> </p>
<ul>
<li><a href="mailto:john.doe@oddmill.com">John Doe</a></li>
<li><a href="mailto:jane.doe@oddmill.com">Jane Doe</a></li>
</ul>
<p>It really is pretty cool though, try it out.<!--  $(document).ready(function() {   var data = $.getJSON("users.json", null, showData);  });  function showData(data) {      var userlistTemplate = TrimPath.parseDOMTemplate("userlist_template");      $("#userlist").html(userlistTemplate.process(data));  } // --></p>
]]></content:encoded>
			<wfw:commentRss>http://slice.nthread.com/2009/04/javascripttemplates-jst/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
