Thursday, December 18, 2008

Simple Maven Archetype

I've been doing more and more with Maven lately. We're currently beginning the effort to migrate some of our stuff to Maven at work. A new feature of the archetype plugin was introduced a bit ago to generate java projects from a menu. This is done using mvn archetype:generate. This provides you with a (hideous) menu of options to begin a new project from a template.

The problem I have with this (besides the menu being hideous) is that Maven still defaults the compiler to use source/target settings for java 1.4. Every project I do that uses Java 1.5 needs to have the compiler config settings tweaked to allow the use of 1.5. It is really annoying, so I created my own simple archetype that I can use and uploaded it to github for easy access. http://github.com/raykrueger/simple-archetype/tree/master

This new archetype generates an empty project with compiler settings for 1.5, includes the dev.java.net maven repository and has dependencies for slf4j and junit.

I may move this archetype project in the future into a collection of archetypes. So I can have a simple java one, a webapp one, and whatever else I come up with. If I do move them, I'll update this blog :)

Sunday, December 07, 2008

Hibernate-memcached 1.1.0 Released!

After a bit of trial and error with the maven release plugin, the latest release of hibernate-memcached is available. This release includes a few new features:
  • Support for the Whalin memcached client
  • New Key strategies: Md5KeyStrategy, Sha1KeyStrategy for reducing the length of keys
  • Better Exception handling during cache failure scenarios

This is the first release after moving the source to github.

I need to do some wiki work to get documentation up for how to enable and configure the Whalin/Danga memcached client. I hope to get to that some time this week.

The new KeyStrategy implementations for Md5 and Sha1 are there to reduce the size of the keys. Raymond He emailed me to point out that the obnoxiously long keys that Hibernate generates take up a lot of memory in memcached. Many records + ~250 char keys = a lot of wasted space. The new Md5 and Sha1 keys strategies simply take the fully qualified key name generated by hibernate-memcached and hash them up to take a lot less space.

The improved exception handling revolves around the addition of a new MemcachedExceptionHandler interface and a default LoggingMemcacheExceptionHandler implementation. Essentially the Spy and Danga memcached clients are wrapped up to eat any exception that comes out of them. There's really no reason for the cache layer to throw exceptions at Hibernate. Errors are logged as Errors, and a null is returned.

Enjoy!