Just a quick note about tools. Over the last couple of months I've been experimenting with the db4o
Java object database. It's compact, yet very powerful and
improving all the time. I prefer the idea of an object database
to using SQL because, although you can get object-relational mapping
layers the fundamental problem is that you have to have SQL under the
hood.


However, like most object databases, db4o comes with it's own problem:
activation. Because an object database is basically a serialized
graph of objects when you read one back you either have to bring back
every object it is associated with, or just bring back some (or maybe
none) of those objects. In the former case you spend a long time
reading objects from the database and spend the memory on them (whether
you use them or not) and in the latter case you end up managing
references to potentially deactivated objects. It's painful
either way round.


I decided to try and tackle this problem using the Dynaop
aspect framework by Bob Lee. It was a chance for me to put Dynaop
through it's paces against a real problem. So far it's looking
very promising. Dynaop is very simple to understand and
implementing activation and storage interceptors (and the corresponding
reflector package for db4o) was not terribly hard.


I was soon able to have domain objects activating and storing
themselves on demand without any actively calling into the persistence
layer. However two things were left: (1) an untidy amount
of "glue" in the form of marker interfaces and configuration files, (2)
transaction support.


The answer to both of these turns out to be xDoclet.
Using some customised xDoclet templates it is possible to generate all
the type factories (required to build the aspect proxied domain
objects), to build the configuration required by the aspect layer, and
also to mark methods which should be considered as transactional.
A lot of this is possible because Dynaop uses the excellent BeanShell to provide run-time configuration and xDoclet can be tailored to generate Beanshell scripts very easily.


The net result is that most aspects of domain object persistence can be
handled with no requirement for the classes themselves to be aware of
the persistence layer at all. All the configuration is dynamic at
run-time and can be automatically generated from comments in the source
code!

Db4o, Dynaop, xDoclet, Beanshell. Java tools sure have come a long way.

[Curiouser and curiouser!]