fix(系统设置): 去掉pf4j的spi服务发现机制

This commit is contained in:
AgAngle 2024-02-26 14:48:05 +08:00 committed by jianxing
parent 946bd807d3
commit 10fbb605f2
4 changed files with 9 additions and 20 deletions

View File

@ -70,15 +70,8 @@ public class JdbcDriverServiceProviderExtensionFinder extends ServiceProviderExt
String pluginId = plugin.getDescriptor().getPluginId(); String pluginId = plugin.getDescriptor().getPluginId();
LogUtils.debug("Reading extensions storages for plugin '{}'", pluginId); LogUtils.debug("Reading extensions storages for plugin '{}'", pluginId);
final Set<String> bucket = new HashSet<>(); final Set<String> bucket = new HashSet<>();
try { try {
Enumeration<URL> urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(ServiceProviderExtensionStorage.EXTENSIONS_RESOURCE); Enumeration<URL> urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(EXTENSIONS_RESOURCE);
if (urls.hasMoreElements()) {
// 如果 ServiceProviderExtensionFinder 无法从 "META-INF/services" 加载才加载
return result;
}
urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(EXTENSIONS_RESOURCE);
if (urls.hasMoreElements()) { if (urls.hasMoreElements()) {
jdbcCollectExtensions(urls, bucket); jdbcCollectExtensions(urls, bucket);
} else { } else {

View File

@ -11,7 +11,6 @@ public class MsPluginManager extends DefaultPluginManager {
@Override @Override
protected ExtensionFinder createExtensionFinder() { protected ExtensionFinder createExtensionFinder() {
DefaultExtensionFinder extensionFinder = (DefaultExtensionFinder) super.createExtensionFinder(); DefaultExtensionFinder extensionFinder = (DefaultExtensionFinder) super.createExtensionFinder();
extensionFinder.addServiceProviderExtensionFinder();
extensionFinder.add(new JdbcDriverServiceProviderExtensionFinder(this)); extensionFinder.add(new JdbcDriverServiceProviderExtensionFinder(this));
return extensionFinder; return extensionFinder;
} }

View File

@ -21,10 +21,9 @@ import io.metersphere.system.mapper.TestResourcePoolMapper;
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper; import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import java.util.List; import java.util.List;
@ -104,10 +103,9 @@ public class BaseResourcePoolTestService {
public void insertResourcePoolProject(TestResourcePool resourcePool) { public void insertResourcePoolProject(TestResourcePool resourcePool) {
ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample(); ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample();
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID); example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID)
example.createCriteria().andTestResourcePoolIdEqualTo(resourcePool.getId()); .andTestResourcePoolIdEqualTo(resourcePool.getId());
List<ProjectTestResourcePool> projectTestResourcePools = projectTestResourcePoolMapper.selectByExample(example); if (projectTestResourcePoolMapper.countByExample(example) == 0) {
if (CollectionUtils.isEmpty(projectTestResourcePools)) {
ProjectTestResourcePool projectTestResourcePool = new ProjectTestResourcePool(); ProjectTestResourcePool projectTestResourcePool = new ProjectTestResourcePool();
projectTestResourcePool.setTestResourcePoolId(resourcePool.getId()); projectTestResourcePool.setTestResourcePoolId(resourcePool.getId());
projectTestResourcePool.setProjectId(DEFAULT_PROJECT_ID); projectTestResourcePool.setProjectId(DEFAULT_PROJECT_ID);
@ -117,10 +115,9 @@ public class BaseResourcePoolTestService {
public void insertResourcePoolOrg(TestResourcePool resourcePool) { public void insertResourcePoolOrg(TestResourcePool resourcePool) {
TestResourcePoolOrganizationExample example = new TestResourcePoolOrganizationExample(); TestResourcePoolOrganizationExample example = new TestResourcePoolOrganizationExample();
example.createCriteria().andOrgIdEqualTo(DEFAULT_ORGANIZATION_ID); example.createCriteria().andOrgIdEqualTo(DEFAULT_ORGANIZATION_ID)
example.createCriteria().andTestResourcePoolIdEqualTo(resourcePool.getId()); .andTestResourcePoolIdEqualTo(resourcePool.getId());
List<TestResourcePoolOrganization> testResourcePoolOrganizations = testResourcePoolOrganizationMapper.selectByExample(example); if (testResourcePoolOrganizationMapper.countByExample(example) == 0) {
if (CollectionUtils.isEmpty(testResourcePoolOrganizations)) {
TestResourcePoolOrganization resourcePoolOrganization = new TestResourcePoolOrganization(); TestResourcePoolOrganization resourcePoolOrganization = new TestResourcePoolOrganization();
resourcePoolOrganization.setTestResourcePoolId(resourcePool.getId()); resourcePoolOrganization.setTestResourcePoolId(resourcePool.getId());
resourcePoolOrganization.setOrgId(DEFAULT_ORGANIZATION_ID); resourcePoolOrganization.setOrgId(DEFAULT_ORGANIZATION_ID);

View File

@ -90,7 +90,7 @@ public class PluginLoadService {
if (!file.exists()) { if (!file.exists()) {
try (InputStream fileAsStream = FileCenter.getDefaultRepository().getFileAsStream(getDefaultRepositoryFileRequest(fileName))) { try (InputStream fileAsStream = FileCenter.getDefaultRepository().getFileAsStream(getDefaultRepositoryFileRequest(fileName))) {
FileUtils.copyInputStreamToFile(fileAsStream, file); FileUtils.copyInputStreamToFile(fileAsStream, file);
loadPlugin(filePath); loadPlugin(fileName);
} catch (Exception e) { } catch (Exception e) {
LogUtils.error("从对象存储加载插件异常", e); LogUtils.error("从对象存储加载插件异常", e);
} }