Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EclipseLink JpaConfiguration to depend on TenantResolver #2242

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading