Class TransactionSynchronizationManagerAdvice
java.lang.Object
com.broadleafcommerce.common.jpa.data.entitymanager.TransactionSynchronizationManagerAdvice
Simple AOP around advice for
TransactionSynchronizationManager
. It is a static utility
class in Spring for managing resources in a transaction. Since it is not a bean, it is more sane
and less brittle to consider customization from an AOP perspective, rather than attempt to unwind
a large call hierarchy to affect similar change.
With Broadleaf data routing, we have occurrences of an EntityManagerFactory backed by a fully routed datasource, and an EntityManagerFactory backed by a traditional datasource targeted at a specific database/schema. Either are valid, and for the purposes of transactional thread binding, they are synonymous. To compress to a single binding (instead of multiple), we intercept calls here to TransactionSynchronizationManager and create a unified key based on the route that either EntityManagerFactory will match against. This allows us to save on the number of EntityManagers that are created for the transaction (avoid redundancy) and also save on the number of connections requested from the DB connection pool as a result.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
static class
-
Method Summary
-
Method Details
-
init
public static void init() -
constructKey
-