Details
The dao.doInTransaction() code blocks are becoming too numerous and
cumbersome (in controller and service classes). We should again look
into setting up Spring's support for declarative transactional behavior
on methods. Now that controllers are spring beans, and not just
JSF-managed beans, we can use Spring to make its methods transactional.
Using declarative transactional behavior will have a few benefits:
- we can be explicit about whether a method needs it own, new txn,
and/or whether it can be nested
- we should be able to handle common exceptions more consistently
(e.g. concurrent mod exceptions)
- we can get rid of all the 'final' variable nonsense required to make
our anonymous DAOTransaction classes work with the params it needs and
the return value it wants to return
- we can have the code that is now in DAOTransaction classes throw
checked exceptions (our DAOTransaction.runTransaction() method does not
declare any thrown checked exceptions, so we've had to make due with
runtime exceptions only). For one we can make our
BusinessRuleViolationException and DataModelViolationException into
checked exceptions. |
Details
The dao.doInTransaction() code blocks are becoming too numerous and
cumbersome (in controller and service classes). We should again look
into setting up Spring's support for declarative transactional behavior
on methods. Now that controllers are spring beans, and not just
JSF-managed beans, we can use Spring to make its methods transactional.
Using declarative transactional behavior will have a few benefits:
- we can be explicit about whether a method needs it own, new txn,
and/or whether it can be nested
- we should be able to handle common exceptions more consistently
(e.g. concurrent mod exceptions)
- we can get rid of all the 'final' variable nonsense required to make
our anonymous DAOTransaction classes work with the params it needs and
the return value it wants to return
- we can have the code that is now in DAOTransaction classes throw
checked exceptions (our DAOTransaction.runTransaction() method does not
declare any thrown checked exceptions, so we've had to make due with
runtime exceptions only). For one we can make our
BusinessRuleViolationException and DataModelViolationException into
checked exceptions. |