|
Delegator
Set transaction boundary for method of Domain Model.
IntroductionBase on Domain-Driven Design, the business logic all move to Domain Model, for example in entity User there is method disable() to disable user. Now in the represent layer, there is a button which invokes this method as user.disable(), but system isn't persist the result because there isn't a transaction around the execution. DetailsNormally, we will add a delegation method in Manager for Domain Model to set transaction boundary. For simplifying the coding, polyforms provides @Delegator for this delegation. Now we only need add a method to interface UserManager like public interface UserManager {
@Delegator
@Transactional
void disable(User user);
}The rule for mapping is basing on method name, and the first parameter of Manager method will be the target Domain Object. You can specify the method name in Domain Object as @Delegator("disable"). Then we just need register UserManager as a spring bean: <util:bean id="userManager" interfaces="cn.muthos.polyforms.sample.manager.UserManager" /> |
Sign in to add a comment