I spent a few hours and banged out some changes to
blojsom using
XStream. The result,
XStream blojsom. If you don't know XStream, it serves as "a simple library to serialize objects to XML and back again." I used XStream 0.3 and made no changes whatsoever to do any aliasing, etc.
So, let me detail its importance, at least related to blojsom.
- I've demonstrated to myself that blojsom's abstraction of the underlying data storage can work. Did it work without changes to core objects? No. Did I think it would work without changes? No. Were those changes severe? Not at all!
- I can now say that we've demonstrated the abstraction works. You can play with the code. Previously I could only say the abstraction was there. Now there's code to backup my claim.
- Related to the abstraction, there's now more than one implemented abstraction for very key aspects to blojsom. Namely, the presentation API, where blojsom can handle JSP, Velocity, and FreeMarker. And now the data storage API, where blojsom can handle simple file-based blogging and XML file-based blogging with XStream.
- In putting together XStream blojsom, there were some changes made to the underlying codebase. Details in a moment.
- XStream makes XML marshalling/unmarshalling quite simple. As such, I did change the Comment and Trackback plugins and the EditBlogEntries plugin to reflect the abstraction. I am now looking at abstraction of the current blojsom API so that no changes to plugins or core objects would be required when migrating to another data storage mechanism. That is, blojsom will improve.
- Things like XML-RPC still work. Rock on!
So, what exactly changed.
- BlogEntry.java - Marked Log instance transient.
- FileBackedBlogEntry.java - Marked Log instance transient.
- XStreamBlogEntry.java - Subclasses from FileBackedBlogEntry.java. Only overrode the load, save, and delete methods to use XStream.
- StandardFetcher.java - All creation of blog entries and categories now uses the newBlogEntry and newBlogCategory methods, respectively.
- XStreamFetcher.java - Subclasses from StandardFetcher.java. Only overrode the newBlogEntry method to return a XStreamBlogEntry object instead of a FileBackedBlogEntry object.
- CommentPlugin.java - As a result of storing all blog information in a single XML file, I simplified the code to add a new comment. I will need to look at how the abstraction can apply to the current file-backed storage.
- TrackbackPlugin.java - As a result of storing all blog information in a single XML file, I simplified the code to add a new trackback. I will need to look at how the abstraction can apply to the current file-backed storage.
- EditBlogEntriesPlugin.java - As a result of storing all blog information in a single XML file, I simplified the code to delete comments and trackbacks.
In any event, the code is out there as the ZIP for people to explore. Once I've resolved core API issues with the comment and trackback handling I will probably add the code to CVS. It would not be terrible to have specific comment and trackback plugins, but if it can be done without any changes to plugins, this would be ideal.
In summary, blojsom is a lightweight blog package written in Java that is inspired by blosxom. blojsom aims to retain the simplicity in design of its Perl-based "relative" while adding user flexibility in areas such as flavors, plugins, storage, and templating.
The code is there to back that up. Enjoy!