An interceptor to be used to start a UnitOfWork if one has not yet been started. If this interceptor creates a new UnitOfWork it will also add a PreResultListener to make sure the unit of work is completed or discarded before the result is executed. This is important so that the rendering of the result does not make any changes to the entities it is dealing with (we can maybe make this an option, to keep the UnitOfWork open until the invocation stack returns to this interceptor or if it should use the PreResultListener, but for now I like the PreResultListener better as it is safer).
When a new UnitOfWork is created by this interceptor a decision must be made when closing it whether to discard the UnitOfWork or complete it. For now, if the resultCode is "success", we complete the UnitOfWork, otherwise we discard it. There are many things we can do here to make it more flexible, e.g. allow the user to specify result codes to complete or, conversely, codes that should result in the UnitOfWork being discarded. Since we have access to the action invocation we could also do something with annotations on the method to be executed to allow user to specify more specifically for that method what results should result in discards or completions.
|
|
|
|
|
|
|
|
|
|