How it works...

Aspects can monitor and control @Transactional methods by including org.springframework.transaction.annotation.Transactional in its Pointcuts. But @Transactional can only be applied to methods that require Spring transaction management such as JPA and Hibernate transactions. For general-purpose methods, a custom transaction-aware annotation must be applied in order for aspects to monitor them.

The class org.springframework.transaction.PlatformTransactionManager is used to implement a general transaction management solution to general bean classes or methods. Together with @Aspect classes, customizing transactions becomes easy by extracting TransactionTemplate from PlatformTransactionManager.

The transactional behavior is executed by the execute () method of TransactionTemplate, which is realized by the advices of the @Aspect that monitors the methods with the help of custom annotation. The inclusion of the custom annotation in its Pointcut triggers the execution of the advice whenever the transaction is executed.

This programmatic style of implementing transaction management is always applied to the service layer. Monitoring secured services can also be done by applying this recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.237.24