连接池参数合并
This commit is contained in:
parent
dc7f4e67ba
commit
c9726dcd59
@ -13,9 +13,11 @@ import java.util.List;
|
|||||||
public class SydApi4Database implements SydApi {
|
public class SydApi4Database implements SydApi {
|
||||||
|
|
||||||
private SydApi4j[] hsms = null;
|
private SydApi4j[] hsms = null;
|
||||||
|
private boolean isShortLinkMode = false;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SydApi4Database() {
|
public SydApi4Database() {
|
||||||
|
isShortLinkMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SydApi4Database(SydApi4j[] hsms) {
|
public SydApi4Database(SydApi4j[] hsms) {
|
||||||
@ -25,20 +27,23 @@ public class SydApi4Database implements SydApi {
|
|||||||
@Override
|
@Override
|
||||||
public SydApi SYD_Connect_Ex(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int iDealTimeOut) {
|
public SydApi SYD_Connect_Ex(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int iDealTimeOut) {
|
||||||
SydApi4j api = (SydApi4j) new SydApi4j().connect(pcIpList[0], iPortList[0], null, iConnectTimeOut);
|
SydApi4j api = (SydApi4j) new SydApi4j().connect(pcIpList[0], iPortList[0], null, iConnectTimeOut);
|
||||||
hsms = new SydApi4j[]{ api };
|
hsms = new SydApi4j[]{api};
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void SYD_Disconnect_Ex() {
|
public void SYD_Disconnect_Ex() {
|
||||||
|
if (isShortLinkMode) {
|
||||||
|
SydApi4j api = hsms[0];
|
||||||
|
if (null != api) {
|
||||||
|
try {
|
||||||
|
api.disconnect();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
api = null;
|
||||||
|
}
|
||||||
// 配合链接池,不再需要释放。
|
// 配合链接池,不再需要释放。
|
||||||
// if ( null != api ) {
|
|
||||||
// try {
|
|
||||||
// api.disconnect();
|
|
||||||
// }catch ( Exception e ){
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// api = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -42,12 +42,25 @@ public class SydApiPool extends ThreadBasedConnectPool<SydApi> {
|
|||||||
|
|
||||||
// 保活接口
|
// 保活接口
|
||||||
protected boolean check(SydApi o) {
|
protected boolean check(SydApi o) {
|
||||||
null != o;
|
if ( null == o ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
o.SYD_SM3_Hash_ShortData( new byte[8] );
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}catch ( Exception e) {
|
||||||
|
// 忽略
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放
|
// 释放
|
||||||
protected void free(SydApi o) {
|
protected void free(SydApi o) {
|
||||||
o.SYD_Disconnect_Ex();
|
if ( null != o ) {
|
||||||
|
o.SYD_Disconnect_Ex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user