How can an encapsulate non-database actions into transactions?
For example, say I have some number of methods/functions called in sequence, some update the database, some update files on the filesystem, some update parameters in the HttpSession, some update the cache, etc. If one of the latter ones fails, like updating the session, how can I roll back all the other changes on the file system, in the DB, etc.?
The environment is a Java Servlet container like Tomcat with something like Struts2, any RDBMS, a persistence layer like Hibernate or Ibatis, etc.