All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.jdbc.TenantDataSourceProvider Maven / Gradle / Ivy

There is a newer version: 5.7.0
Show newest version
package com.holonplatform.jdbc;

import java.util.Optional;

import javax.sql.DataSource;

import com.holonplatform.core.Context;

/**
 * Concrete tenant {@link DataSource} instance provider.
 * 

* This interface is used by {@link MultiTenantDataSource} to obtain the concrete {@link DataSource} to use with the * current tenant id. *

* * @since 4.3.0 */ @FunctionalInterface public interface TenantDataSourceProvider { /** * Default {@link Context} resource reference */ public static final String CONTEXT_KEY = TenantDataSourceProvider.class.getName(); /** * Provides the concrete {@link DataSource} to use with given tenantId * @param tenantId Tenant id * @return the DataSource reference */ DataSource getDataSource(String tenantId); /** * Convenience method to obtain the current {@link TenantDataSourceProvider} made available as {@link Context} * resource, using default {@link ClassLoader}. *

* See {@link Context#resource(String, Class)} for details about context resources availability conditions. *

* @return Optional TenantDataSourceProvider, empty if not available as context resource */ static Optional getCurrent() { return Context.get().resource(CONTEXT_KEY, TenantDataSourceProvider.class); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy