Category Archives: Uncategorized

java.util.concurrent.Executors

I think java.util.concurrent.Executors (and related functionality like Futures) is one of the best features of JDK 1.5.

One small feature I'd like, though – a newCachedThreadPool(int nThreads) factory method that combines the features of newCachedThreadPool() and newFixedThreadPool(int nThreads). It would create a thread pool that creates new threads as needed up to the number specified by nThreads reusing previously constructed threads when they are available.

This functionality is available directly in java.util.concurrent.ThreadPoolExecutor, but a factory method would be delightful. Surely I'm not the only person who would find a thread pool with a max limit on size that shrinks after use more useful than either a FixedThreadPool or an unbound CachedThreadPool?

An Open API that should exist

Here's an idea for free. Someone should setup a photo-printing site with an Open API which all the thousands of free image sharing sites
could use to get their images printed. The printing site would pay commissions to the sharing sites and would handle all the billing etc.
(Paying commissions is pretty normal for photo printing sites – some pay up to 25% of an order, but all require the user to manually upload the pictures to their site.)

It's a win for everyone – if you want to build the next FlickR you would have a potential income stream. If you are a consumer you get to choose the best sharing site, and
finally if the printer operator wins because of increased number of orders coming though from the affiliate sites.

SmugMug has (AFAIK) the closest I've seen to an implementation of this idea. They have an upload API and printing
capabilities, but it is primarly a photo sharing site which you need to join to get pictures printed.

Fixing Velocity's character encoding problems

I quite like writing quick web applications using Spring and Velocity. I've often been annoyed by the fact that I quite often get character encoding problems:

Encoding problem

Today I finally got around to looking into this and fixing it. It turns out that Velocity defaults to using the ISO-8859-1 encoding. Using Spring's VelocityViewResolver this can be changed:


	<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
		<property name="cache" value="true"/>
		<property name="prefix" value=""/>
		<property name="suffix" value=".vm"/>
		<property name="contentType" value="text/html; charset=UTF-8"/>
	</bean>

With that change characters display as expected:
Problems Fixed

As usual: if I'd known how easy it was I'd have done it sooner…

Melbourne LongTailCamp on Friday

There's a LongTailCamp in Melbourne on Friday. I'd love to make it, but (a) I've got prior commitments and (b) while I have some working code for my current million-dollar-idea I'd prefer to do a knock-your-socks off demo rather than the that's-kind-of-different functionality I have at the moment.

More coverage:

Don't clone the Google Search API

There have been a few calls lately to clone the Google Search API. I don't think this is a good idea – the world has moved on since the Google API was specified in 2002, and using SOAP for this kind of thing no longer looks like the good idea it seemed then.

As someone who does a lot of work with search APIs (writing them my day job and consuming them in my Argos search engine API) I'd much prefer to see Google support the OpenSearch API.

However, there is an additional problem beyond standardising the request-response API: there is no standard query language (ignoring CQL for the moment, as no one uses it) and I don't think there is much of a prospect for that to change for a while.