Skip to content

Commit ca151d7

Browse files
committed
Revert "dbeaver/pro#7415 Simplify platform configuration (dbeaver#39602)"
This reverts commit ad27aff.
1 parent fe3f98d commit ca151d7

File tree

12 files changed

+69
-93
lines changed

12 files changed

+69
-93
lines changed

plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DesktopPlatform.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717

1818
package org.jkiss.dbeaver.core;
1919

20-
import org.eclipse.core.runtime.Platform;
2120
import org.eclipse.core.runtime.Plugin;
2221
import org.eclipse.ui.PlatformUI;
2322
import org.jkiss.code.NotNull;
2423
import org.jkiss.dbeaver.DBException;
2524
import org.jkiss.dbeaver.DBeaverPreferences;
2625
import org.jkiss.dbeaver.Log;
27-
import org.jkiss.dbeaver.model.DBConfigurationController;
2826
import org.jkiss.dbeaver.model.DBConstants;
2927
import org.jkiss.dbeaver.model.DBPExternalFileManager;
3028
import org.jkiss.dbeaver.model.app.*;
@@ -50,7 +48,6 @@
5048
import org.jkiss.dbeaver.utils.SystemVariablesResolver;
5149
import org.jkiss.utils.CommonUtils;
5250
import org.jkiss.utils.StandardConstants;
53-
import org.osgi.framework.Bundle;
5451

5552
import java.io.File;
5653
import java.io.IOException;
@@ -321,15 +318,4 @@ public boolean isShuttingDown() {
321318
return isClosing();
322319
}
323320

324-
@NotNull
325-
@Override
326-
public DBConfigurationController getPluginConfigurationController(@NotNull String pluginId) {
327-
Bundle bundle = Platform.getBundle(pluginId);
328-
if (bundle == null) {
329-
throw new IllegalStateException("Bundle '" + pluginId + "' not found");
330-
}
331-
return getConfigurationController(bundle);
332-
}
333-
334-
335321
}

plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/registry/GeometryViewerRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static void populateFromConfig(
121121
@NotNull Collection<String> notVisiblePredefinedTilesIds,
122122
@NotNull Collection<LeafletTilesDescriptor> userDefinedTiles
123123
) throws DBException {
124-
String content = DBWorkbench.getPlatform().getConfigurationController().loadConfigurationFile(GEOMETRY_REGISTRY_CONFIG_XML);
124+
String content = DBWorkbench.getPlatform().getProductConfigurationController().loadConfigurationFile(GEOMETRY_REGISTRY_CONFIG_XML);
125125
if (CommonUtils.isEmpty(content)) {
126126
return;
127127
}
@@ -296,7 +296,7 @@ private void flushConfig() {
296296
xmlBuilder.flush();
297297
out.flush();
298298

299-
DBWorkbench.getPlatform().getConfigurationController()
299+
DBWorkbench.getPlatform().getProductConfigurationController()
300300
.saveConfigurationFile(GEOMETRY_REGISTRY_CONFIG_XML, out.getBuffer().toString());
301301
} catch (Throwable e) {
302302
log.error("Error saving " + GeometryViewerRegistry.class.getName() + " configuration");

plugins/org.jkiss.dbeaver.headless/src/org/jkiss/dbeaver/headless/DBeaverTestPlatform.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
package org.jkiss.dbeaver.headless;
1919

2020
import org.eclipse.core.resources.ResourcesPlugin;
21-
import org.eclipse.core.runtime.Platform;
2221
import org.eclipse.core.runtime.Plugin;
2322
import org.jkiss.code.NotNull;
2423
import org.jkiss.dbeaver.Log;
25-
import org.jkiss.dbeaver.model.DBConfigurationController;
2624
import org.jkiss.dbeaver.model.DBConstants;
2725
import org.jkiss.dbeaver.model.DBPExternalFileManager;
2826
import org.jkiss.dbeaver.model.app.*;
@@ -180,12 +178,6 @@ public DBPExternalFileManager getExternalFileManager() {
180178
return workspace;
181179
}
182180

183-
@NotNull
184-
@Override
185-
public DBConfigurationController getPluginConfigurationController(@NotNull String pluginId) {
186-
return getConfigurationController(Platform.getBundle(pluginId));
187-
}
188-
189181
@Override
190182
public boolean isWorkbenchStarted() {
191183
return true;

plugins/org.jkiss.dbeaver.model.dashboard/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Export-Package: org.jkiss.dbeaver.model.dashboard,
1414
Require-Bundle: org.eclipse.core.expressions,
1515
org.jkiss.dbeaver.model;visibility:=reexport,
1616
org.jkiss.dbeaver.registry;visibility:=reexport,
17-
org.jkiss.dbeaver.model.rcp,
1817
com.google.gson
1918
Bundle-Localization: OSGI-INF/l10n/bundle
2019
Automatic-Module-Name: org.jkiss.dbeaver.model.dashboard

plugins/org.jkiss.dbeaver.model.dashboard/src/org/jkiss/dbeaver/model/dashboard/registry/DashboardRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
2727
import org.jkiss.dbeaver.model.DBPNamedObject;
2828
import org.jkiss.dbeaver.model.WorkspaceConfigEventManager;
29-
import org.jkiss.dbeaver.model.app.DBPPlatformDesktop;
3029
import org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor;
3130
import org.jkiss.dbeaver.model.connection.DBPDriver;
3231
import org.jkiss.dbeaver.model.dashboard.DBDashboardContext;
@@ -99,11 +98,11 @@ private void loadConfigFromFile() {
9998
.loadConfigurationFile(CONFIG_FILE_NAME);
10099
if (CommonUtils.isEmpty(configContent) && !DBWorkbench.isDistributed()) {
101100
// Backward compatibility
102-
configContent = DBPPlatformDesktop.getInstance()
101+
configContent = DBWorkbench.getPlatform()
103102
.getPluginConfigurationController(DashboardConstants.DASHBOARDS_LEGACY_PLUGIN_ID)
104103
.loadConfigurationFile(CONFIG_FILE_NAME);
105104
if (CommonUtils.isEmpty(configContent)) {
106-
configContent = DBPPlatformDesktop.getInstance()
105+
configContent = DBWorkbench.getPlatform()
107106
.getPluginConfigurationController(DashboardConstants.DASHBOARDS_LEGACY_PLUGIN_ID2)
108107
.loadConfigurationFile(CONFIG_FILE_NAME);
109108
}

plugins/org.jkiss.dbeaver.model.rcp/src/org/jkiss/dbeaver/model/app/DBPPlatformDesktop.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.jkiss.dbeaver.model.app;
1919

2020
import org.jkiss.code.NotNull;
21-
import org.jkiss.dbeaver.model.DBConfigurationController;
2221
import org.jkiss.dbeaver.model.DBPExternalFileManager;
2322
import org.jkiss.dbeaver.runtime.DBWorkbench;
2423

@@ -33,13 +32,6 @@ public interface DBPPlatformDesktop extends DBPPlatform, DBPPlatformEventManager
3332
@NotNull
3433
DBPExternalFileManager getExternalFileManager();
3534

36-
/**
37-
* Returns configuration controller,
38-
* which keeps plugin configuration which can be shared with other users.
39-
*/
40-
@NotNull
41-
DBConfigurationController getPluginConfigurationController(@NotNull String pluginId);
42-
4335
static DBPPlatformDesktop getInstance() {
4436
return DBWorkbench.getPlatform(DBPPlatformDesktop.class);
4537
}

plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPApplicationConfigurator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DBeaver - Universal Database Manager
3-
* Copyright (C) 2010-2025 DBeaver Corp and others
3+
* Copyright (C) 2010-2024 DBeaver Corp and others
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818
package org.jkiss.dbeaver.model.app;
1919

2020
import org.jkiss.code.NotNull;
21+
import org.jkiss.code.Nullable;
2122
import org.jkiss.dbeaver.model.DBConfigurationController;
2223
import org.jkiss.dbeaver.model.DBFileController;
2324
import org.jkiss.dbeaver.model.task.DBTTaskController;
@@ -32,7 +33,7 @@ public interface DBPApplicationConfigurator {
3233
* Keeps configuration which can be shared with other users.
3334
*/
3435
@NotNull
35-
DBConfigurationController createConfigurationController(@NotNull String pluginId);
36+
DBConfigurationController createConfigurationController(@Nullable String pluginId);
3637

3738
@NotNull
3839
DBFileController createFileController();

plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.jkiss.dbeaver.model.app;
1919

2020
import org.jkiss.code.NotNull;
21+
import org.jkiss.code.Nullable;
2122
import org.jkiss.dbeaver.model.DBConfigurationController;
2223
import org.jkiss.dbeaver.model.DBFileController;
2324
import org.jkiss.dbeaver.model.connection.DBPDataSourceProviderRegistry;
@@ -93,6 +94,20 @@ public interface DBPPlatform {
9394
*/
9495
@NotNull
9596
DBConfigurationController getConfigurationController();
97+
98+
/**
99+
* Returns configuration controller,
100+
* which keeps product configuration which can be shared with other users.
101+
*/
102+
@NotNull
103+
DBConfigurationController getProductConfigurationController();
104+
105+
/**
106+
* Returns configuration controller,
107+
* which keeps plugin configuration which can be shared with other users.
108+
*/
109+
@NotNull
110+
DBConfigurationController getPluginConfigurationController(@Nullable String pluginId);
96111

97112
/**
98113
* Local config files are used to store some configuration specific to local machine only.

plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/registry/formatter/DataFormatterRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private synchronized List<DBDDataFormatterProfile> getCustomProfilesInternal() {
140140
private synchronized void loadProfiles() {
141141
customProfiles = new ArrayList<>();
142142
try {
143-
String content = DBWorkbench.getPlatform().getConfigurationController().loadConfigurationFile(CONFIG_FILE_NAME);
143+
String content = DBWorkbench.getPlatform().getProductConfigurationController().loadConfigurationFile(CONFIG_FILE_NAME);
144144
if (CommonUtils.isEmpty(content)) {
145145
return;
146146
}
@@ -189,7 +189,7 @@ private synchronized void saveProfiles() {
189189
xml.flush();
190190

191191
out.flush();
192-
DBWorkbench.getPlatform().getConfigurationController()
192+
DBWorkbench.getPlatform().getProductConfigurationController()
193193
.saveConfigurationFile(CONFIG_FILE_NAME, out.getBuffer().toString());
194194
} catch (Throwable ex) {
195195
log.warn("Failed to save data formatter profiles to " + CONFIG_FILE_NAME, ex);

plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/BasePlatformImpl.java

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.eclipse.core.runtime.Platform;
2020
import org.eclipse.core.runtime.Plugin;
2121
import org.jkiss.code.NotNull;
22+
import org.jkiss.code.Nullable;
2223
import org.jkiss.dbeaver.DBException;
2324
import org.jkiss.dbeaver.Log;
2425
import org.jkiss.dbeaver.ModelPreferences;
@@ -199,51 +200,47 @@ public DBWHandlerRegistry getNetworkHandlerRegistry() {
199200

200201
@NotNull
201202
@Override
202-
public synchronized DBConfigurationController getConfigurationController() {
203-
if (defaultConfigurationController == null) {
204-
Plugin productPlugin = getProductPlugin();
205-
if (productPlugin == null) {
206-
throw new IllegalStateException("Product plugin not found");
207-
}
208-
if (getApplication() instanceof DBPApplicationConfigurator appConfigurator) {
209-
defaultConfigurationController = appConfigurator.createConfigurationController(productPlugin.getBundle().getSymbolicName());
210-
} else {
211-
LocalConfigurationController controller = new LocalConfigurationController(getLocalWorkspaceConfigFolder());
212-
Path pluginStateLocation = RuntimeUtils.getPluginStateLocation(productPlugin);
213-
if (Files.exists(pluginStateLocation)) {
214-
controller.setLegacyConfigFolder(pluginStateLocation);
215-
}
216-
defaultConfigurationController = controller;
217-
}
218-
}
219-
return defaultConfigurationController;
203+
public DBConfigurationController getConfigurationController() {
204+
return getPluginConfigurationController(null);
220205
}
221-
222-
protected DBConfigurationController getConfigurationController(@NotNull Bundle bundle) {
223-
DBConfigurationController controller = configurationControllerByPlugin.get(bundle);
206+
207+
@NotNull
208+
@Override
209+
public DBConfigurationController getProductConfigurationController() {
210+
return getConfigurationController(getProductPlugin().getBundle());
211+
}
212+
213+
@NotNull
214+
@Override
215+
public DBConfigurationController getPluginConfigurationController(@Nullable String pluginId) {
216+
return getConfigurationController(CommonUtils.isEmpty(pluginId) ? null : Platform.getBundle(pluginId));
217+
}
218+
219+
private DBConfigurationController getConfigurationController(@Nullable Bundle bundle) {
220+
DBConfigurationController controller = bundle == null ? defaultConfigurationController : configurationControllerByPlugin.get(bundle);
224221
if (controller == null) {
225-
controller = createConfigurationControllerForBundle(bundle);
226-
configurationControllerByPlugin.put(bundle, controller);
222+
controller = createConfigurationController(bundle);
223+
if (bundle == null) {
224+
defaultConfigurationController = controller;
225+
} else {
226+
configurationControllerByPlugin.put(bundle, controller);
227+
}
227228
}
228229
return controller;
229230
}
230231

231232
@NotNull
232233
@Override
233-
public DBConfigurationController createConfigurationController(@NotNull String pluginId) {
234-
Bundle bundle = Platform.getBundle(pluginId);
235-
if (bundle == null) {
236-
throw new IllegalStateException("Bundle '" + pluginId + "' not found");
237-
}
238-
return createConfigurationControllerForBundle(bundle);
234+
public DBConfigurationController createConfigurationController(@Nullable String pluginId) {
235+
return createConfigurationController(pluginId == null ? null : Platform.getBundle(pluginId));
239236
}
240237

241238
@NotNull
242-
protected DBConfigurationController createConfigurationControllerForBundle(@NotNull Bundle bundle) {
239+
private DBConfigurationController createConfigurationController(@Nullable Bundle bundle) {
243240
DBPApplication application = getApplication();
244-
if (application instanceof DBPApplicationConfigurator appConfigurator) {
241+
if (application instanceof DBPApplicationConfigurator) {
245242
String pluginBundleName = bundle == null ? null : bundle.getSymbolicName();
246-
return appConfigurator.createConfigurationController(pluginBundleName);
243+
return ((DBPApplicationConfigurator) application).createConfigurationController(pluginBundleName);
247244
} else if (bundle == null) {
248245
LocalConfigurationController controller = new LocalConfigurationController(
249246
getLocalWorkspaceConfigFolder()

0 commit comments

Comments
 (0)