The Unit Of Work pattern is a common pattern in enterprise application architectures.
It implements the concept of an "application transaction" that keeps track of:
- dirty objects
- new objects
- removed objects
Fowler defines the Unit Of Work like this in his book Patterns of Enterprise Application Architecture:
Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems
The user can implement listeners that allows him to trigger additional behaviour on specific events, such as begin, commit, rollback, dispose etc.
All listeners must implement that
The Unit Of Work will not commit until all listeners have agreed on that. If for example on listener have set the transaction to rollBackOnly then the whole Unit Of Work transaction will rollback.
The listeners are added to the Unit Of Work in the