Currently I'm developing a somewhat small and generic indexing system, that generates a full inverted index (used for searching words within a document). To do this I have decided I want minimise the impact on the developer to actually use this feature and hijack the PersistenceManager object (used in JDO to write data to the database).
To do this I am using an interceptor to wrap the PersistenceManagerFactory, this interceptor ... intercepts all method calls that return a PersistenceManager (getPersistenceManager, getPersistenceManagerProxy, etc). This is all in order to programmatically add another interceptor to the PersistenceManager, that in turn processes the functions that match the expression:
This is where I start writing to the datastore (oh I'm using Google App Engine for this, but I doubt that is important).
This approach actually works, although it seems a little messy. I was wondering whether it is possible to attach advice directly to a PersistenceManager? Rather than having to do it my way? The issue I see is that I never actually create the PersistenceManager within the Spring XML file, they are always new objects obtained by the PMF, hence no ProxyFactoryBean can be added to it. This was the original reasoning for my somewhat odd implementation.