diff --git a/src/org/redkale/source/DataAsyncSource.java b/src/org/redkale/source/DataAsyncSource.java new file mode 100644 index 000000000..d56be40c0 --- /dev/null +++ b/src/org/redkale/source/DataAsyncSource.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.redkale.source; + +import java.util.function.Function; +import org.redkale.service.*; +import org.redkale.util.*; + +/** + * DataSource的异步抽象实现类 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ +@Local +@AutoLoad(false) +@SuppressWarnings("unchecked") +@ResourceType(DataSource.class) +public abstract class DataAsyncSource extends AbstractService implements DataSource, DataCacheListener, Function, AutoCloseable, Resourcable { + +} diff --git a/src/org/redkale/source/DataJdbcSource.java b/src/org/redkale/source/DataJdbcSource.java index 711bfb941..bc419e668 100644 --- a/src/org/redkale/source/DataJdbcSource.java +++ b/src/org/redkale/source/DataJdbcSource.java @@ -35,7 +35,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC protected static final Flipper FLIPPER_ONE = new Flipper(1); - protected final Logger logger = Logger.getLogger(DataJdbcSource.class.getSimpleName()); + protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); protected String name; @@ -105,8 +105,9 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC protected void preConstruct(String unitName, Properties readprop, Properties writeprop) { final AtomicInteger counter = new AtomicInteger(); this.threads = Integer.decode(readprop.getProperty(JDBC_CONNECTIONSMAX, "" + Runtime.getRuntime().availableProcessors() * 16)); + final String cname = this.getClass().getSimpleName(); final Thread.UncaughtExceptionHandler ueh = (t, e) -> { - logger.log(Level.SEVERE, "DataJdbcSource error", e); + logger.log(Level.SEVERE, cname + " error", e); }; this.executor = Executors.newFixedThreadPool(threads, (Runnable r) -> { Thread t = new Thread(r); @@ -117,7 +118,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC } else if (s.length() == 2) { s = "0" + s; } - t.setName("DataJdbcSource-Thread-" + s); + t.setName(cname + "-Thread-" + s); t.setUncaughtExceptionHandler(ueh); return t; }); @@ -126,9 +127,9 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC protected void initByProperties(String unitName, Properties readprop, Properties writeprop) { this.name = unitName; this.conf = null; + this.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty(JDBC_CACHE_MODE)); this.readPool = new PoolJdbcSource(this, "read", readprop); this.writePool = new PoolJdbcSource(this, "write", writeprop); - this.cacheForbidden = "NONE".equalsIgnoreCase(readprop.getProperty(JDBC_CACHE_MODE)); } @Local