Skip to content

VassilisSoum/spring-custom-transaction-interceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom TransactionInterceptor for Spring Boot

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.

Steps required

  1. Create a class extending the TransactionInterceptor class. Take a look at com.custom.transaction.CustomTransactionInterceptor
  2. Define the beans as in com.custom.transaction.example.ExampleConfig
  3. In application.properties or application.yml allow overriding spring beans by setting spring.main.allow-bean-definition-overriding=true

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages