Skip to content

Commit

Permalink
EclipseLink JpaConfiguration to depend on TenantResolver (#2242)
Browse files Browse the repository at this point in the history
minimize dependencies

Signed-off-by: Avgustin Marinov <[email protected]>
  • Loading branch information
avgustinmm authored Jan 27, 2025
1 parent e3c41eb commit 5cc4372
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
@Configuration
public class JpaConfiguration extends JpaBaseConfiguration {

private final TenantAware tenantAware;
private final TenantAware.TenantResolver tenantResolver;

protected JpaConfiguration(
final DataSource dataSource, final JpaProperties properties,
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
final TenantAware tenantAware) {
final TenantAware.TenantResolver tenantResolver) {
super(dataSource, properties, jtaTransactionManagerProvider);
this.tenantAware = tenantAware;
this.tenantResolver = tenantResolver;
}

/**
Expand All @@ -53,7 +53,7 @@ protected JpaConfiguration(
@Override
@Bean
public PlatformTransactionManager transactionManager(final ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
return new MultiTenantJpaTransactionManager(tenantAware);
return new MultiTenantJpaTransactionManager(tenantResolver);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MultiTenantJpaTransactionManager extends JpaTransactionManager {
@Serial
private static final long serialVersionUID = 1L;

private transient TenantAware tenantAware;
private transient TenantAware.TenantResolver tenantResolver;

private static final Class<?> JPA_TARGET;

Expand All @@ -52,8 +52,8 @@ class MultiTenantJpaTransactionManager extends JpaTransactionManager {
}
}

MultiTenantJpaTransactionManager(final TenantAware tenantAware) {
this.tenantAware = tenantAware;
MultiTenantJpaTransactionManager(final TenantAware.TenantResolver tenantResolver) {
this.tenantResolver = tenantResolver;
}

private static final EntityPropertyChangeListener ENTITY_PROPERTY_CHANGE_LISTENER = new EntityPropertyChangeListener();
Expand All @@ -78,7 +78,7 @@ protected void doBegin(final Object transaction, final TransactionDefinition def
}
}

final String currentTenant = tenantAware.getCurrentTenant();
final String currentTenant = tenantResolver.resolveTenant();
if (currentTenant == null) {
cleanupTenant(em);
} else {
Expand Down

0 comments on commit 5cc4372

Please sign in to comment.