Browse Source

Merge pull request #14340 in DESIGN/design from mss/2.0 to fbp-1.0

* commit '8a069f4f6873df7b6393e47fb386700de1afb8f7':
  REPORT-126235  放开插件的classFinder
  REPORT-114392 FR-FBP版本本地设计适配 修复数据连接与数据集问题
fbp-1.0
superman 4 months ago
parent
commit
a793ec7ae1
  1. 18
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java
  2. 6
      designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java
  3. 158
      designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java

18
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java vendored

@ -10,12 +10,19 @@ import com.fanruan.carina.annotions.Supplemental;
import com.fanruan.config.impl.data.ConnectionConfigProviderFactory; import com.fanruan.config.impl.data.ConnectionConfigProviderFactory;
import com.fanruan.config.impl.data.ConnectionConfigWriter; import com.fanruan.config.impl.data.ConnectionConfigWriter;
import com.fanruan.config.impl.data.ConnectionConfigWriterFactory; import com.fanruan.config.impl.data.ConnectionConfigWriterFactory;
import com.fanruan.config.impl.data.TableDataConfigProviderFactory;
import com.fanruan.data.ConnectionConfigWrapper;
import com.fr.data.driver.classloader.DriverClassLoaderHelper;
import com.fr.data.driver.classloader.impl.ChildFirstDriverClassLoader;
import com.fr.data.driver.classloader.impl.ChildOnlyDriverClassLoader;
import com.fr.data.driver.constants.DriverLoaderStrategies;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionPluginProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionPluginProcessor;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDYConnectionProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDYConnectionProcessor;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JNDIConnectionProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JNDIConnectionProcessor;
import com.fr.design.data.datapane.connect.LocalConnectionSource; import com.fr.design.data.datapane.connect.LocalConnectionSource;
import com.fr.file.TableDataConfigWrapper;
import com.fr.workspace.server.repository.connection.ConnectionWriterShell; import com.fr.workspace.server.repository.connection.ConnectionWriterShell;
import com.fr.workspace.server.repository.connection.LocalConnectionShell; import com.fr.workspace.server.repository.connection.LocalConnectionShell;
@ -50,11 +57,20 @@ public class DesignDatasourceComponent extends DatasourceComponent {
*/ */
@Start @Start
public void start() { public void start() {
super.start(); // 服务器数据集与数据连接设计器这边先手动切为finedb存储,后续数据中心适配后再切为他们提供的wrapper
ConnectionConfigProviderFactory.registerConnectionConfigProvider(ConnectionConfigWrapper.getInstance());
TableDataConfigProviderFactory.getInstance().registerTableDataConfigProvider(new TableDataConfigWrapper());
registerDriverClassLoader();
ConnectionConfigWriterFactory.registerConnectionConfigWriter((ConnectionConfigWriter) ConnectionConfigProviderFactory.getConfigProvider()); ConnectionConfigWriterFactory.registerConnectionConfigWriter((ConnectionConfigWriter) ConnectionConfigProviderFactory.getConfigProvider());
Carina.getApplicationContext().singleton(ConnectionWriterShell.class).set(ConnectionConfigWriterFactory.getConfigWriter()); Carina.getApplicationContext().singleton(ConnectionWriterShell.class).set(ConnectionConfigWriterFactory.getConfigWriter());
} }
private void registerDriverClassLoader() {
DriverClassLoaderHelper.INSTANCE.register(DriverLoaderStrategies.CHILD_FIRST, ChildFirstDriverClassLoader.class);
DriverClassLoaderHelper.INSTANCE.register(DriverLoaderStrategies.CHILD_ONLY, ChildOnlyDriverClassLoader.class);
}
/** /**
* stop * stop
*/ */

6
designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java

@ -45,6 +45,7 @@ import com.fr.locale.LocaleScope;
import com.fr.locale.LocaleUtils; import com.fr.locale.LocaleUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.measure.DBMeterFactory; import com.fr.measure.DBMeterFactory;
import com.fr.plugin.manage.PluginManager;
import com.fr.record.DefaultDBMeter; import com.fr.record.DefaultDBMeter;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics; import com.fr.record.analyzer.Metrics;
@ -56,6 +57,7 @@ import com.fr.stable.bridge.StableFactory;
import com.fr.stable.fun.WebLocaleProvider; import com.fr.stable.fun.WebLocaleProvider;
import com.fr.stable.plugin.ExtraClassManagerProvider; import com.fr.stable.plugin.ExtraClassManagerProvider;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.resource.ResourceLoader;
import com.fr.stable.xml.StableXMLUtils; import com.fr.stable.xml.StableXMLUtils;
import com.fr.start.DesignerProcessType; import com.fr.start.DesignerProcessType;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
@ -216,6 +218,10 @@ public class DesignPreLoadComponent {
} }
return Class.forName(className, true, urlClassLoader); return Class.forName(className, true, urlClassLoader);
}); });
ClassFactory.getInstance().addFinder(className -> ResourceLoader.classForName(className));
ClassFactory.getInstance().addFinder(className -> Class.forName(className, true, PluginManager.getController().getClass().getClassLoader()));
} }

158
designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java

@ -0,0 +1,158 @@
package com.fanruan.data;
import com.fanruan.config.impl.data.ConnectionConfigProvider;
import com.fanruan.config.impl.data.ConnectionConfigWriter;
import com.fr.data.impl.Connection;
import com.fr.file.ConnectionConfig;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerAdaptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
/**
* 对数据连接的配置封装包装了事务
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/7/30
*/
public class ConnectionConfigWrapper implements ConnectionConfigProvider, ConnectionConfigWriter {
private static final ConnectionConfigWrapper INSTANCE = new ConnectionConfigWrapper();
private ConnectionConfigWrapper() {
}
public static ConnectionConfigWrapper getInstance() {
return INSTANCE;
}
@Override
public Map<String, Connection> getConnections() {
Map<String, Connection> connectionMap = new HashMap<>(ConnectionConfig.getInstance().getConnections());
for (Map.Entry<String, Connection> entry : connectionMap.entrySet()) {
entry.getValue().setConnectionName(entry.getKey());
}
return connectionMap;
}
@Override
public Map<String, Connection> getConnectionsWithoutCheck() {
Map<String, Connection> connectionMap = new HashMap<>(ConnectionConfig.getInstance().getConnectionsWithoutCheck());
for (Map.Entry<String, Connection> entry : connectionMap.entrySet()) {
entry.getValue().setConnectionName(entry.getKey());
}
return connectionMap;
}
@Override
public <T extends Connection> Map<String, T> getDesignateConnections(Class<T> clazz) {
Map<String, T> connectionMap = new HashMap<>(ConnectionConfig.getInstance().getDesignateConnections(clazz));
for (Map.Entry<String, T> entry : connectionMap.entrySet()) {
entry.getValue().setConnectionName(entry.getKey());
}
return connectionMap;
}
@Override
public void addConnection(String connectionName, Connection connection) {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().addConnection(connectionName, connection);
}
});
}
@Override
public int getRemainingCon(int remove, int add) {
return ConnectionConfig.getInstance().getRemainingCon(remove, add);
}
@Override
public void addConnectionWithoutCheck(String connectionName, Connection connection) {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().addConnectionWithoutCheck(connectionName, connection);
}
});
}
@Override
public void removeConnection(String connectionName) {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().removeConnection(connectionName);
}
});
}
@Override
public void renameConnection(String oldName, String newName) {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().renameConnection(oldName, newName);
}
});
}
@Override
public @Nullable Connection getConnection(@NotNull String connectionName) {
Connection connection = ConnectionConfig.getInstance().getConnection(connectionName);
if (connection != null) {
connection.setConnectionName(connectionName);
}
return connection;
}
@Override
public @Nullable Connection getConnectionWithoutCheck(String connectionName) {
Connection connection = ConnectionConfig.getInstance().getConnectionWithoutCheck(connectionName);
if (connection != null) {
connection.setConnectionName(connectionName);
}
return connection;
}
@Override
public void removeAllConnection() {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().removeAllConnection();
}
});
}
@Override
public void updateConnection(String connName, Connection connection) {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().addConnection(connName, connection);
}
});
}
@Override
public boolean isPutPermitted() {
return ConnectionConfig.getInstance().isPutPermitted();
}
@Override
public void safeRemoveAll() {
Configurations.update(new WorkerAdaptor(ConnectionConfig.class) {
@Override
public void run() {
ConnectionConfig.getInstance().safeRemoveAll();
}
});
}
}
Loading…
Cancel
Save