mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/pro#2181 DI + platform initialization refactoring (#2190)
* dbeaver/pro#2181 DI + platform initialization refactoring * dbeaver/pro#2181 Tests headless environment
This commit is contained in:
+1
@@ -231,6 +231,7 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements
|
||||
|
||||
@Override
|
||||
public Object start(IApplicationContext context) {
|
||||
initializeApplicationServices();
|
||||
try {
|
||||
startServer();
|
||||
} catch (Exception e) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class WebSessionWorkspace implements DBPWorkspace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WebProjectImpl getProjectById(String projectId) {
|
||||
public WebProjectImpl getProjectById(@NotNull String projectId) {
|
||||
if (projectId == null) {
|
||||
return activeProject;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,6 @@
|
||||
<extension-point id="io.cloudbeaver.driver" name="Web drivers" schema="schema/io.cloudbeaver.driver.exsd"/>
|
||||
<extension-point id="io.cloudbeaver.handler" name="Web handlers" schema="schema/io.cloudbeaver.handler.exsd"/>
|
||||
|
||||
<extension point="org.eclipse.core.runtime.adapters">
|
||||
<factory adaptableType="org.jkiss.dbeaver.runtime.DBWorkbench" class="io.cloudbeaver.server.WebPlatformAdapterFactory">
|
||||
<adapter type="org.jkiss.dbeaver.model.app.DBPPlatform"/>
|
||||
<adapter type="org.jkiss.dbeaver.runtime.ui.DBPPlatformUI"/>
|
||||
</factory>
|
||||
</extension>
|
||||
|
||||
|
||||
<!-- Needed to instantiate connections thru navigator model -->
|
||||
<extension point="org.jkiss.dbeaver.service">
|
||||
<service name="org.jkiss.dbeaver.runtime.DBServiceConnections" class="io.cloudbeaver.server.WebServiceConnectionsImpl"/>
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.ModelPreferences;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
|
||||
import org.jkiss.dbeaver.model.app.DBPApplication;
|
||||
import org.jkiss.dbeaver.model.app.DBPPlatform;
|
||||
import org.jkiss.dbeaver.model.auth.AuthInfo;
|
||||
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
|
||||
import org.jkiss.dbeaver.model.data.json.JSONUtils;
|
||||
@@ -58,6 +59,7 @@ import org.jkiss.dbeaver.registry.BaseApplicationImpl;
|
||||
import org.jkiss.dbeaver.registry.DataSourceNavigatorSettings;
|
||||
import org.jkiss.dbeaver.runtime.DBWorkbench;
|
||||
import org.jkiss.dbeaver.runtime.IVariableResolver;
|
||||
import org.jkiss.dbeaver.runtime.ui.DBPPlatformUI;
|
||||
import org.jkiss.dbeaver.utils.ContentUtils;
|
||||
import org.jkiss.dbeaver.utils.GeneralUtils;
|
||||
import org.jkiss.dbeaver.utils.PrefUtils;
|
||||
@@ -1249,4 +1251,15 @@ public abstract class CBApplication extends BaseWebApplication implements WebAut
|
||||
var sslConfiguration = Path.of(sslConfigurationPath);
|
||||
return sslConfiguration.isAbsolute() ? sslConfiguration : getHomeDirectory().resolve(sslConfiguration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Class<? extends DBPPlatform> getPlatformClass() {
|
||||
return CBPlatform.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DBPPlatformUI> getPlatformUIClass() {
|
||||
return CBPlatformUI.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CBPlatform extends BasePlatformImpl {
|
||||
return WebPlatformActivator.getInstance().getPreferences();
|
||||
}
|
||||
|
||||
private CBPlatform() {
|
||||
CBPlatform() {
|
||||
}
|
||||
|
||||
public static void setApplication(CBApplication application) {
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2023 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.cloudbeaver.server;
|
||||
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.jkiss.dbeaver.model.app.DBPPlatform;
|
||||
import org.jkiss.dbeaver.runtime.DBWorkbench;
|
||||
import org.jkiss.dbeaver.runtime.ui.DBPPlatformUI;
|
||||
|
||||
public class WebPlatformAdapterFactory implements IAdapterFactory {
|
||||
|
||||
private static final Class<?>[] CLASSES = new Class[] { DBPPlatform.class, DBPPlatformUI.class };
|
||||
|
||||
@Override
|
||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||
if (adaptableObject instanceof DBWorkbench) {
|
||||
if (adapterType == DBPPlatform.class) {
|
||||
return adapterType.cast(CBPlatform.getInstance());
|
||||
} else if (adapterType == DBPPlatformUI.class) {
|
||||
return adapterType.cast(CBPlatformUI.INSTANCE);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getAdapterList() {
|
||||
return CLASSES;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user