优化代码逻辑,使用ServiceLoader加载未知类的实例
This commit is contained in:
98
logs-201904/sncp-log-20190428.log
Normal file
98
logs-201904/sncp-log-20190428.log
Normal file
@@ -0,0 +1,98 @@
|
||||
四月 28, 2019 6:17:11 下午 [Transport-Thread-3] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:17:11 下午 [Transport-Thread-3] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:18:34 下午 [Transport-Thread-6] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:18:34 下午 [Transport-Thread-6] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:23:34 下午 [Transport-Thread-2] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:24:04 下午 [Transport-Thread-2] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:24:44 下午 [Transport-Thread-4] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:24:44 下午 [Transport-Thread-4] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:24:44 下午 [Transport-Thread-7] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:24:44 下午 [Transport-Thread-7] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:24:47 下午 [Transport-Thread-3] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:24:47 下午 [Transport-Thread-3] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
四月 28, 2019 6:25:08 下午 [Transport-Thread-6] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
四月 28, 2019 6:25:08 下午 [Transport-Thread-6] org.redkale.net.sncp.SncpClient$1$1 completed
|
||||
严重: public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String) sncp (params: ["3421432"]) deal error
|
||||
java.lang.RuntimeException: remote service(public net.tccn.base.JBean net.tccn.service.MetadataService.serviceList(java.lang.String)) deal error (retcode=1073741824, retinfo=Inner exception)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:437)
|
||||
at org.redkale.net.sncp.SncpClient$1$1.completed(SncpClient.java:396)
|
||||
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
|
||||
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
|
||||
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
|
||||
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
|
||||
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
|
||||
at java.lang.Thread.run(Thread.java:748)
|
||||
|
||||
@@ -13,7 +13,7 @@ const plat = {
|
||||
return red.getX('/plat/db_list', params)
|
||||
},
|
||||
dbSave({plat}) {
|
||||
return red.postX('/plat/db_save', {plat})
|
||||
return red.postX('/plat/db_save', {plat:JSON.stringify(plat)})
|
||||
},
|
||||
|
||||
}
|
||||
BIN
root/u/table/redkale-543220437634186_table.xls
Normal file
BIN
root/u/table/redkale-543220437634186_table.xls
Normal file
Binary file not shown.
BIN
root/u/table/redkale-543272247486082_table.xls
Normal file
BIN
root/u/table/redkale-543272247486082_table.xls
Normal file
Binary file not shown.
BIN
root/u/table/table.xls
Normal file
BIN
root/u/table/table.xls
Normal file
Binary file not shown.
@@ -1,14 +1,11 @@
|
||||
package net.tccn.base;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -278,8 +275,7 @@ public class ExcelKit {
|
||||
|
||||
List<Map> list = new ArrayList<>();
|
||||
int t = 0;
|
||||
r:
|
||||
for (int i = 0; i <= lastRowNum; i++) {
|
||||
r:for (int i = 0; i <= lastRowNum; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
if (row == null) continue;
|
||||
short cellNum = row.getLastCellNum();
|
||||
@@ -376,7 +372,8 @@ public class ExcelKit {
|
||||
}
|
||||
|
||||
private static Workbook getWorkbook(File file) throws IOException {
|
||||
Workbook wk;
|
||||
return WorkbookFactory.create(file);
|
||||
/*Workbook wk;
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
try {
|
||||
wk = new HSSFWorkbook(fis);//if excel version 2007+ will throws OfficeXmlFileException
|
||||
@@ -392,6 +389,6 @@ public class ExcelKit {
|
||||
}
|
||||
}
|
||||
|
||||
return wk;
|
||||
return wk;*/
|
||||
}
|
||||
}
|
||||
|
||||
9
src/main/java/net/tccn/base/IService.java
Normal file
9
src/main/java/net/tccn/base/IService.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.tccn.base;
|
||||
|
||||
/**
|
||||
* ServiceLoader 管理标识
|
||||
* @author: liangxianyou
|
||||
*/
|
||||
public interface IService {
|
||||
String getType();
|
||||
}
|
||||
@@ -65,4 +65,24 @@ public class Liangs {
|
||||
return toArray(list);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type 待加载的class 类型
|
||||
* @param name class 的实现名称
|
||||
* @param <T> 泛型<T>
|
||||
* @return
|
||||
*/
|
||||
public static <T extends IService> T getDbSource(Class<T> type, String name) {
|
||||
ServiceLoader<T> loader = ServiceLoader.load(type);
|
||||
Iterator<T> iterator = loader.iterator();
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
T dbSource = iterator.next();
|
||||
if (name.equalsIgnoreCase(dbSource.getType())) {
|
||||
return dbSource;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import lombok.Data;
|
||||
import net.tccn.base.arango.Doc;
|
||||
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库平台
|
||||
@@ -21,7 +20,7 @@ public class DbAccount extends Doc<DbAccount> {
|
||||
private String url; //数据库连接地址
|
||||
private String user; //账号
|
||||
private String pwd; //密码
|
||||
private List<String> catalogs; //库
|
||||
private String[] catalogs; //库
|
||||
|
||||
//----------------------------
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.tccn.dbq.jdbc.api;
|
||||
|
||||
import net.tccn.base.Liangs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -14,9 +16,12 @@ public class DbKit implements DbSource{
|
||||
|
||||
public DbKit(DbAccount dbAccount) {
|
||||
this.dbAccount = dbAccount;
|
||||
if ("mysql".equalsIgnoreCase(dbAccount.getCate())) {
|
||||
dbSource = new DbSourceMysql(dbAccount);
|
||||
} else {
|
||||
try {
|
||||
DbSource dbSource = Liangs.getDbSource(DbSource.class, dbAccount.getCate());
|
||||
dbSource.setDbAccount(dbAccount);
|
||||
|
||||
this.dbSource = dbSource;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(String.format("创建DbKit失败:数据库类型[cate:%s]未知", dbAccount.getCate()));
|
||||
}
|
||||
}
|
||||
@@ -31,6 +36,11 @@ public class DbKit implements DbSource{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDbAccount(DbAccount dbAccount) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> findList(String sql, Class<T> type) {
|
||||
return dbSource.findList(sql, type);
|
||||
@@ -73,4 +83,9 @@ public class DbKit implements DbSource{
|
||||
public CompletableFuture<Void> exetuteAsync(String sql) {
|
||||
return CompletableFuture.runAsync(() -> exetute(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package net.tccn.dbq.jdbc.api;
|
||||
|
||||
import net.tccn.base.IService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by liangxianyou at 2019/3/12 14:07.
|
||||
*/
|
||||
public interface DbSource {
|
||||
public interface DbSource extends IService {
|
||||
|
||||
void setDbAccount(DbAccount dbAccount);
|
||||
|
||||
<T> List<T> findList(String sql, Class<T> type);
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@ public class DbSourceMysql implements DbSource {
|
||||
private DbAccount dbAccount;
|
||||
private String catalog;
|
||||
|
||||
public DbSourceMysql() {
|
||||
|
||||
}
|
||||
|
||||
public void setDbAccount(DbAccount dbAccount) {
|
||||
this.dbAccount = dbAccount;
|
||||
this.accountKey = dbAccount.accountKey();
|
||||
}
|
||||
|
||||
public DbSourceMysql(DbAccount dbAccount) {
|
||||
this.dbAccount = dbAccount;
|
||||
this.accountKey = dbAccount.accountKey();
|
||||
@@ -33,6 +42,11 @@ public class DbSourceMysql implements DbSource {
|
||||
this.accountKey = dbAccount.accountKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "mysql";
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> findList(String sql, Class<T> type) {
|
||||
Connection connection = connection();
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
net.tccn.dbq.jdbc.api.DbSourceMysql
|
||||
@@ -20,7 +20,10 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user