Cleaned up a bit
This commit is contained in:
@@ -27,8 +27,6 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
* {@link TenantAware#getCurrentTenant()} in the eclipselink session. This has
|
||||
* to be done in eclipselink after a {@link Transaction} has been started.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -44,13 +42,8 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
|
||||
.getResource(getEntityManagerFactory());
|
||||
final EntityManager em = emHolder.getEntityManager();
|
||||
|
||||
if (!definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants")
|
||||
&& !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant")
|
||||
&& !definition.getName()
|
||||
.startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator")
|
||||
&& !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler")
|
||||
&& !definition.getName()
|
||||
.startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata")) {
|
||||
if (notTenantManagement(definition) && notCurrentTenantKeyGenerator(definition)
|
||||
&& notRolloutScheduler(definition) && notGetOrCreateTenantMetadata(definition)) {
|
||||
|
||||
final String currentTenant = tenantAware.getCurrentTenant();
|
||||
if (currentTenant == null) {
|
||||
@@ -60,4 +53,23 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
|
||||
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notGetOrCreateTenantMetadata(final TransactionDefinition definition) {
|
||||
return !definition.getName()
|
||||
.startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata");
|
||||
}
|
||||
|
||||
private boolean notRolloutScheduler(final TransactionDefinition definition) {
|
||||
return !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler");
|
||||
}
|
||||
|
||||
private boolean notCurrentTenantKeyGenerator(final TransactionDefinition definition) {
|
||||
return !definition.getName()
|
||||
.startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator");
|
||||
}
|
||||
|
||||
private boolean notTenantManagement(final TransactionDefinition definition) {
|
||||
return !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant")
|
||||
&& !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user