This repository contains a custom TransactionInterceptor for Spring Boot. The TransactionInterceptor
is a Spring AOP interceptor that intercepts all methods annotated with the @Transactional
annotation.
The TransactionInterceptor is a custom implementation of
the org.aopalliance.intercept.MethodInterceptor
interface. It is used to intercept method
invocations and execute custom logic before and after the method invocation.
In this example we use the custom TransactionInterceptor to handle transaction management for the com.soumakis.control.Try monad to be able to express exceptions as types in the method signature.
However, feel free to customize it to suit your needs or open a PR with suggestions and improvements.
- Create a class extending the
TransactionInterceptor
class. Take a look atcom.custom.transaction.CustomTransactionInterceptor
- Define the beans as in
com.custom.transaction.example.ExampleConfig
- In
application.properties
orapplication.yml
allow overriding spring beans by settingspring.main.allow-bean-definition-overriding=true