From 0ecd8b8c158436b23298b66b64eaef0438b6425b Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期二, 17 六月 2025 09:36:53 +0800 Subject: [PATCH] art: SAP集成测试代码修改 --- src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java | 59 +++++++++++++---------------------------------------------- 1 files changed, 13 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java b/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java index 5463389..876add9 100644 --- a/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java +++ b/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java @@ -1,19 +1,21 @@ package org.jeecg.config.sap; -import com.sap.conn.jco.*; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoDestinationManager; +import com.sap.conn.jco.JCoException; import com.sap.conn.jco.ext.DestinationDataProvider; import com.sap.conn.jco.ext.Environment; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; -import java.io.File; -import java.io.FileOutputStream; import java.util.Properties; @Component @Slf4j +@Getter public class SapRfcConnectionManager { @Value("${sap.rfc.destination}") @@ -37,10 +39,13 @@ @Value("${sap.rfc.lang}") private String lang; - private String poolSize = "5"; + @Value("${sap.rfc.poolSize}") + private String poolSize; - private String idleTimeout = "10000"; + @Value("${sap.rfc.expirationTime}") + private String expirationTime; + @Value("${sap.rfc.peekLimit}") private String peekLimit = "10"; private JCoDestination destination; @@ -60,53 +65,15 @@ connectProperties.setProperty(DestinationDataProvider.JCO_LANG, lang); connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, peekLimit); connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, poolSize); - connectProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_TIME, idleTimeout); + connectProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_TIME, expirationTime); // 鍒涘缓鍔ㄦ�佺洰鐨勫湴锛堥伩鍏嶄緷璧� SM59 閰嶇疆锛� -// CustomDestinationDataProvider provider = new CustomDestinationDataProvider(); -// provider.addDestination(destinationName, connectProperties); + CustomDestinationDataProvider provider = new CustomDestinationDataProvider(destinationName, connectProperties); // 璁剧疆鍏ㄥ眬鐩殑鍦版彁渚涜�� -// Environment.registerDestinationDataProvider(provider); - - log.info("properties = " + connectProperties); - - //鐢熸垚閰嶇疆鏂囦欢锛孞CoDestinationManager.getDestination()璋冪敤鏃朵細闇�瑕佽杩炴帴閰嶇疆鏂囦欢锛屽悗缂�鍚嶉渶瑕佷负jcoDestination - FileOutputStream fos = null; - String suffix = "jcoDestination"; - File cfg = new File(destinationName + "." + suffix); - if (!cfg.exists()) { - try { - fos = new FileOutputStream(cfg, false); - connectProperties.store(fos, "for tests only !"); - fos.close(); - } catch (Exception var9) { - throw new Exception("Unable to create the destination file " + cfg.getName(), var9); - } finally { - if (null != fos) { - fos.close(); - } - } - } + Environment.registerDestinationDataProvider(provider); // 鑾峰彇鐩殑鍦� this.destination = JCoDestinationManager.getDestination(destinationName); - } - - /** - * - * @return - */ - public JCoDestination getDestination() { - return destination; - } - - /** - * - */ - public void destroy() { - if (destination != null) { -// destination; - } } } \ No newline at end of file -- Gitblit v1.9.3