diff --git a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/PluginStore.java b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/PluginStore.java index 285bbceaf..b88258aa0 100644 --- a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/PluginStore.java +++ b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/PluginStore.java @@ -302,7 +302,7 @@ public synchronized SetPluginsResult setPlugins(IPluginContext pluginContext, Op if (this.plugins != null) { this.plugins.forEach((plugin) -> { if (plugin instanceof AfterPluginSaved) { - ((AfterPluginSaved) plugin).afterSaved( pluginContext, context); + ((AfterPluginSaved) plugin).afterSaved(pluginContext, context); } }); } diff --git a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DBConfig.java b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DBConfig.java index 50f3a0150..7837f3aea 100644 --- a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DBConfig.java +++ b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DBConfig.java @@ -25,6 +25,9 @@ import com.qlangtech.tis.plugin.IRepositoryTargetFile; import com.qlangtech.tis.runtime.module.misc.IMessageHandler; import com.qlangtech.tis.runtime.module.misc.impl.AdapterMessageHandler; +import com.qlangtech.tis.util.RobustReflectionConverter2; +import com.qlangtech.tis.util.RobustReflectionConverter2.PluginMetas; +import com.qlangtech.tis.web.start.TisAppLaunch; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -135,7 +138,7 @@ public void vistDbName(IProcess p) throws Exception { } } - public static final int expireSec = 15; + public static final int expireSec = TisAppLaunch.isTestMock() ? 200 : 15; public void vistDbURL(boolean resolveHostIp, IDbUrlProcess urlProcess) { vistDbURL(resolveHostIp, expireSec, urlProcess); @@ -276,6 +279,7 @@ public boolean vistDbURL(boolean resolveHostIp, IDbUrlProcess urlProcess }); try { final JDBCConnectionPool connectionPool = JDBCConnection.connectionPool.get(); + final PluginMetas pluginMetas = RobustReflectionConverter2.usedPluginInfo.get(); int dbCount = 0; for (Map.Entry> entry : this.getDbEnum().entrySet()) { dbCount += entry.getValue().size(); @@ -302,6 +306,8 @@ public boolean vistDbURL(boolean resolveHostIp, IDbUrlProcess urlProcess if (connectionPool != null) { JDBCConnection.connectionPool.set(connectionPool); } + RobustReflectionConverter2.usedPluginInfo.set(pluginMetas); + fjdbcUrl.set(jdbcUrl); urlProcess.visit((facade ? name : dbName), dbHost, (jdbcUrl)); } catch (Throwable e) { @@ -311,7 +317,7 @@ public boolean vistDbURL(boolean resolveHostIp, IDbUrlProcess urlProcess if (connectionPool != null) { JDBCConnection.connectionPool.remove(); } - // IRepositoryTargetFile.TARGET_FILE_CONTEXT.remove(); + RobustReflectionConverter2.usedPluginInfo.remove(); } }); if (facade) { @@ -422,7 +428,7 @@ public interface IProcess { * @param dbName * @return */ - boolean visit(DBConfig config, String jdbcUrl, String ip, String dbName) throws Exception; + boolean visit(DBConfig config, String jdbcUrl, String ip, String dbName) throws Exception; } public interface IDbUrlProcess { diff --git a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DataSourceFactory.java b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DataSourceFactory.java index 45c2cfa20..8a9dd3cd0 100644 --- a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DataSourceFactory.java +++ b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/DataSourceFactory.java @@ -126,7 +126,7 @@ protected Class getExpectDesClass protected void validateConnection(String jdbcUrl, IConnProcessor p) throws TableNotFoundException { JDBCConnection conn = null; try { - conn = this.createConnection(jdbcUrl, true); // getConnection(jdbcUrl, true); + conn = this.getConnection(jdbcUrl, true); // getConnection(jdbcUrl, true); p.vist(conn); } catch (TableNotFoundException e) { throw e; @@ -183,8 +183,13 @@ public final JDBCConnection getConnection(String jdbcUrl, boolean verify) throws if (connectionPool != null) { conn = connectionPool.getConnection(jdbcUrl, verify); if (conn == null) { - conn = createConnection(jdbcUrl, verify); - return connectionPool.setConnection(jdbcUrl, verify, conn); + return connectionPool.getConnection(jdbcUrl, verify, (url) -> { + try { + return createConnection(jdbcUrl, verify); + } catch (SQLException e) { + throw new RuntimeException(e); + } + }); } else { return conn; } @@ -201,11 +206,11 @@ public final JDBCConnection getConnection(String jdbcUrl, boolean verify) throws * @return * @throws SQLException */ - public JDBCConnection createConnection(String jdbcUrl, boolean verify) throws SQLException { + protected JDBCConnection createConnection(String jdbcUrl, boolean verify) throws SQLException { throw new UnsupportedOperationException("class:" + this.getClass().getName() + ",jdbcUrl:" + jdbcUrl); } - public JDBCConnection getConnection(String jdbcUrl, boolean usingPool, boolean verify) throws SQLException { + public JDBCConnection getConnection(String jdbcUrl, boolean usingPool, boolean verify) throws SQLException { return this.getConnection(jdbcUrl, verify); } diff --git a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/JDBCConnectionPool.java b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/JDBCConnectionPool.java index 607fc7964..762ce9588 100644 --- a/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/JDBCConnectionPool.java +++ b/tis-plugin/src/main/java/com/qlangtech/tis/plugin/ds/JDBCConnectionPool.java @@ -18,6 +18,8 @@ package com.qlangtech.tis.plugin.ds; +import java.util.function.Function; + /** * @author: 百岁(baisui@qlangtech.com) * @create: 2024-10-05 19:40 @@ -25,5 +27,6 @@ public abstract class JDBCConnectionPool { public abstract JDBCConnection getConnection(String jdbcUrl, boolean verify); - public abstract JDBCConnection setConnection(String jdbcUrl, boolean verify, JDBCConnection conn); + public abstract JDBCConnection getConnection(String jdbcUrl, boolean verify, Function mappingFunction); + //public abstract JDBCConnection setConnection(String jdbcUrl, boolean verify, JDBCConnection conn); } diff --git a/tis-web-config/config.properties b/tis-web-config/config.properties index d5b916fe8..b86fad89f 100644 --- a/tis-web-config/config.properties +++ b/tis-web-config/config.properties @@ -30,8 +30,8 @@ tis.datasource.type=derby tis.datasource.dbname=tis_console_db -assemble.host=192.168.28.107 -tis.host=192.168.28.107 +assemble.host=192.168.28.109 +tis.host=192.168.28.109