001package io.ebean.config;
002
003/**
004 * The mode to use for multi-tenancy.
005 */
006public enum TenantMode {
007
008  /**
009   * No multi-tenancy.
010   */
011  NONE(false, true),
012
013  /**
014   * Each Tenant has their own Database (javax.sql.DataSource)
015   */
016  DB(true, false),
017
018  /**
019   * Each Tenant has their own Database schema.
020   */
021  SCHEMA(true, false),
022
023  /**
024   * Each Tenant has their own Database but with in connection pool
025   */
026  CATALOG(true, false),
027
028  /**
029   * Tenants share tables but have a discriminator/partition column that partitions the data.
030   */
031  PARTITION(false, true),
032
033  /**
034   * Each Tenant has their own Database (javax.sql.DataSource), and there is also one master-database
035   * (that holds configuration e.g.)
036   */
037  DB_WITH_MASTER(true, true);
038
039  final boolean dynamicDataSource;
040  final boolean ddlEnabled;
041
042  TenantMode(boolean dynamicDataSource, boolean ddlEnabled) {
043    this.dynamicDataSource = dynamicDataSource;
044    this.ddlEnabled = ddlEnabled;
045  }
046
047  /**
048   * Return true if the DataSource is not available on bootup.
049   */
050  public boolean isDynamicDataSource() {
051    return dynamicDataSource;
052  }
053
054  /**
055   * Returns true, if DDL is enabled.
056   */
057  public boolean isDdlEnabled() {
058    return ddlEnabled;
059  }
060
061}