|
From: Rod J. <rod...@in...> - 2003-05-16 06:35:58
|
This is a rough example, not meant as a guide to good practice, but just my play area... Hence the use of SQL queries for everything, rather than cached data. However, it does show declarative tx mgt via AOP, and the tx rollback works nicely. The AOP stuff is in the test-servlet.xml bean file. Note how the bank target is an implementation of the bo.Bank interface, while the publicly exposed bank object is an AOP proxy. The declarative tx behaviour is specified by the transactionAttributeSource property of the transaction interceptor. Of course the tx interceptor could be shared (like the datasource in Ken's application) across all servlets by being specified in applicationContext.xml. Another interesting possibility is shown by making the createController (which creates the tables) transactional via AOP. Of course you wouldn't normally want to make a web controller transactional (preferring tx delimitation in business objects) but it's transparent to the MVC infrastructure, hence works nicely. Could be useful with legacy code. The readonly interceptor to prevent a JSP from calling update methods is an experiment with the idea of JSPs having limited access to domain objects, without always needing a bean. Not sure about this. Of course it should really be implemented via a ReadOnly metadata attribute rather than the hardcoded interceptor as in the example. The example works with the default HSQL db shipped with Orion 2.01. Regards, Rod |