View Javadoc
1   package com.atlassian.activeobjects.spi;
2   
3   import com.atlassian.tenancy.api.Tenant;
4   
5   import javax.annotation.Nonnull;
6   import javax.sql.DataSource;
7   
8   /**
9    * Gives access to the host application data source.
10   */
11  public interface TenantAwareDataSourceProvider {
12      /**
13       * Provide host application data source associated with a tenant.
14       *
15       * This data source will be used for the entire lifetime of {@code com.atlassian.activeobjects.external.ActiveObjects}
16       */
17      @Nonnull
18      DataSource getDataSource(@Nonnull final Tenant tenant);
19  
20      /**
21       * <p>Returns the database type for the tenant</p>
22       * <p>Note: if {@link com.atlassian.activeobjects.spi.DatabaseType#UNKNOWN} is return it is left up to the client of
23       * the data source provider to 'guess' the type of the database. It is strongly advised to implement this method so
24       * that it never returns {@link com.atlassian.activeobjects.spi.DatabaseType#UNKNOWN}.</p>
25       *
26       * @return a valid database type
27       * @see com.atlassian.activeobjects.spi.DatabaseType
28       */
29      @Nonnull
30      DatabaseType getDatabaseType(@Nonnull final Tenant tenant);
31  
32      /**
33       * <p>The name of the schema used with this database for the tenant.</p>
34       * <p>This is especially import for SQL Server, PostgresQL and HSQLDB</p>
35       *
36       * @return the name of the schema to use, {@code null} if no schema is required.
37       */
38      String getSchema(@Nonnull final Tenant tenant);
39  }