Skip to content

Commit

Permalink
* 整理配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
fjn committed Jan 14, 2021
1 parent 6b20ac8 commit 2077605
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void setDelegate(DataSource delegate) {
@Override
public boolean isSlave() {
if (properties != null) {
if (properties.isReadOnly() || !properties.isPrimary()) {
if (properties.isReadonly() || !properties.isPrimary()) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class DataSourceProperties implements Configuration {
private String catalog;
private String schema;

private boolean isReadOnly;
private boolean isReadonly;
private boolean isAutoCommit;
/**
* 可选值:
Expand Down Expand Up @@ -88,7 +88,7 @@ public DataSourceProperties() {
this.maxPoolSize = 10;
this.minIdle = 10;
this.isAutoCommit = true;
this.isReadOnly = false;
this.isReadonly = false;
}

public String getGroup() {
Expand Down Expand Up @@ -243,12 +243,12 @@ public void setValidationQuery(final String validationQuery) {
this.validationQuery = Strings.getNullIfEmpty(validationQuery);
}

public boolean isReadOnly() {
return this.isReadOnly;
public boolean isReadonly() {
return this.isReadonly;
}

public void setReadOnly(final boolean readOnly) {
this.isReadOnly = readOnly;
public void setReadonly(final boolean readonly) {
this.isReadonly = readonly;
}

public String getTransactionIsolation() {
Expand Down Expand Up @@ -304,7 +304,7 @@ public String toString() {
", password='" + password + '\'' +
", catalog='" + catalog + '\'' +
", schema='" + schema + '\'' +
", isReadOnly=" + isReadOnly +
", isReadOnly=" + isReadonly +
", isAutoCommit=" + isAutoCommit +
", transactionIsolation='" + transactionIsolation + '\'' +
", leakDetectionThresholdInMills=" + leakDetectionThresholdInMills +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static DataSource createDataSource(final DataSourceProperties properties)
}

props.setProperty(PROP_DEFAULT_AUTO_COMMIT, "" + properties.isAutoCommit());
props.setProperty(PROP_DEFAULT_READ_ONLY, "" + properties.isReadOnly());
props.setProperty(PROP_DEFAULT_READ_ONLY, "" + properties.isReadonly());
Isolation isolation = Transactions.getTransactionIsolation(properties.getTransactionIsolation());
if (Transactions.isValidIsolation(isolation)) {
props.setProperty(PROP_DEFAULT_TRANSACTION_ISOLATION, properties.getTransactionIsolation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.jn.sqlhelper.datasource.factory.dbcp2;

import com.jn.langx.util.Maths;
import com.jn.langx.util.Strings;
import com.jn.langx.util.Throwables;
import com.jn.sqlhelper.common.transaction.utils.Isolation;
import com.jn.sqlhelper.common.transaction.utils.Transactions;
Expand Down Expand Up @@ -64,7 +63,7 @@ public static DataSource createDataSource(DataSourceProperties properties) {
}

props.setProperty(PROP_DEFAULT_AUTO_COMMIT, "" + properties.isAutoCommit());
props.setProperty(PROP_DEFAULT_READ_ONLY, "" + properties.isReadOnly());
props.setProperty(PROP_DEFAULT_READ_ONLY, "" + properties.isReadonly());
Isolation isolation = Transactions.getTransactionIsolation(properties.getTransactionIsolation());
if (Transactions.isValidIsolation(isolation)) {
props.setProperty(PROP_DEFAULT_TRANSACTION_ISOLATION, isolation.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.jn.langx.util.Maths;
import com.jn.langx.util.Strings;
import com.jn.langx.util.Throwables;
import com.jn.sqlhelper.common.transaction.utils.Isolation;
import com.jn.sqlhelper.common.transaction.utils.Transactions;
Expand Down Expand Up @@ -62,7 +61,7 @@ public static DataSource createDataSource(DataSourceProperties properties) {
}

props.setProperty(PROP_DEFAULTAUTOCOMMIT, "" + properties.isAutoCommit());
props.setProperty(PROP_DEFAULTREADONLY, "" + properties.isReadOnly());
props.setProperty(PROP_DEFAULTREADONLY, "" + properties.isReadonly());
Isolation isolation = Transactions.getTransactionIsolation(properties.getTransactionIsolation());
if (Transactions.isValidIsolation(isolation)) {
props.setProperty(PROP_DEFAULTTRANSACTIONISOLATION, isolation.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static DataSource createDataSource(final DataSourceProperties props) {
config.setTransactionIsolation(isolation.getDisplayText());
}

config.setReadOnly(props.isReadOnly());
config.setReadOnly(props.isReadonly());
return new HikariDataSource(config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static DataSource createDataSource(final DataSourceProperties properties)
}

props.setProperty(PROP_AUTO_COMMIT, "" + properties.isAutoCommit());
props.setProperty(PROP_READONLY, "" + properties.isReadOnly());
props.setProperty(PROP_READONLY, "" + properties.isReadonly());
Isolation isolation = Transactions.getTransactionIsolation(properties.getTransactionIsolation());
if (Transactions.isValidIsolation(isolation)) {
props.setProperty(PROP_TRANSACTION_ISOLATION, isolation.getName());
Expand Down

0 comments on commit 2077605

Please sign in to comment.