Exemplo n.º 1
0
  /**
   * Constructor with DataSource
   *
   * @param dataSource the dataSource, can not be null
   */
  public Config(String name, DataSource dataSource) {
    if (StrKit.isBlank(name)) throw new IllegalArgumentException("Config name can not be blank");
    if (dataSource == null) throw new IllegalArgumentException("DataSource can not be null");

    this.name = name.trim();
    this.dataSource = dataSource;
  }
Exemplo n.º 2
0
  /**
   * Constructor with full parameters
   *
   * @param dataSource the dataSource, can not be null
   * @param dialect the dialect, set null with default value: new MysqlDialect()
   * @param showSql the showSql,set null with default value: false
   * @param devMode the devMode, set null with default value: false
   * @param transactionLevel the transaction level, set null with default value:
   *     Connection.TRANSACTION_READ_COMMITTED
   * @param containerFactory the containerFactory, set null with default value: new
   *     IContainerFactory(){......}
   * @param cache the cache, set null with default value: new EhCache()
   */
  public Config(
      String name,
      DataSource dataSource,
      Dialect dialect,
      Boolean showSql,
      Boolean devMode,
      Integer transactionLevel,
      IContainerFactory containerFactory,
      ICache cache) {
    if (StrKit.isBlank(name)) throw new IllegalArgumentException("Config name can not be blank");
    if (dataSource == null) throw new IllegalArgumentException("DataSource can not be null");

    this.name = name.trim();
    this.dataSource = dataSource;

    if (dialect != null) this.dialect = dialect;
    if (showSql != null) this.showSql = showSql;
    if (devMode != null) this.devMode = devMode;
    if (transactionLevel != null) this.transactionLevel = transactionLevel;
    if (containerFactory != null) this.containerFactory = containerFactory;
    if (cache != null) this.cache = cache;
  }