Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/dbeaver-vscode#45 server feature extension #3075

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/bundles/io.cloudbeaver.model/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<plugin>
<extension-point id="io.cloudbeaver.service" name="Web services" schema="schema/io.cloudbeaver.service.exsd"/>
<extension-point id="io.cloudbeaver.feature" name="Web features" schema="schema/io.cloudbeaver.feature.exsd"/>
<extension-point id="io.cloudbeaver.server.feature" name="Web server features" schema="schema/io.cloudbeaver.server.feature.exsd"/>
<extension-point id="io.cloudbeaver.valueSerializer" name="Web value serializers" schema="schema/io.cloudbeaver.valueSerializer.exsd"/>
<extension-point id="org.jkiss.dbeaver.auth.provider" name="%extension-point.org.jkiss.dbeaver.authProvider.name" schema="schema/org.jkiss.dbeaver.authProvider.exsd"/>
<extension-point id="io.cloudbeaver.metaParameters" name="Meta parameters" schema="schema/io.cloudbeaver.metaParameters.exsd"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.model" id="io.cloudbeaver.server.feature" name="Web features"/>
</appInfo>
<documentation>
Web feature
</documentation>
</annotation>

<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="feature"/>
</sequence>
</complexType>
</element>

<element name="feature">
<annotation>
<documentation>
Web service description
</documentation>
</annotation>
</element>


</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 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.registry;

import io.cloudbeaver.DBWFeatureSet;
import io.cloudbeaver.utils.WebAppUtils;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.impl.AbstractContextDescriptor;

/**
* WebFeatureDescriptor
*/
public class WebServerFeatureDescriptor extends AbstractContextDescriptor implements DBWFeatureSet {

public static final String EXTENSION_ID = "io.cloudbeaver.server.feature"; //$NON-NLS-1$

private final String id;
private final String label;
private final String description;
private final DBPImage icon;

public WebServerFeatureDescriptor(IConfigurationElement config)
{

Check warning on line 40 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureDescriptor.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 '{' at column 5 should be on the previous line. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureDescriptor.java:40:5: warning: '{' at column 5 should be on the previous line. (com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck)
super(config);
this.id = config.getAttribute("id");
this.label = config.getAttribute("label");
this.description = config.getAttribute("description");
this.icon = iconToImage(config.getAttribute("icon"));
}

@NotNull
public String getId() {
return id;
}

@NotNull
public String getLabel() {
return label;
}

public String getDescription() {
return description;
}

@Override
public DBPImage getIcon() {
return icon;
}

@Override
public boolean isEnabled() {
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 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.registry;

import io.cloudbeaver.DBWFeatureSet;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.dbeaver.Log;

import java.util.ArrayList;
import java.util.List;

public class WebServerFeatureRegistry {

private static final Log log = Log.getLog(WebServerFeatureRegistry.class);

private static final String TAG_FEATURE = "feature"; //$NON-NLS-1$

private static WebServerFeatureRegistry instance = null;

public synchronized static WebServerFeatureRegistry getInstance() {

Check warning on line 36 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java:36:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)

Check warning on line 36 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'static' modifier out of order with the JLS suggestions. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java:36:25: warning: 'static' modifier out of order with the JLS suggestions. (com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck)
if (instance == null) {
instance = new WebServerFeatureRegistry();
instance.loadExtensions(Platform.getExtensionRegistry());
}
return instance;
}

private String[] serverFeatures = new String[0];

private WebServerFeatureRegistry() {
}

private synchronized void loadExtensions(IExtensionRegistry registry) {
IConfigurationElement[] extConfigs = registry.getConfigurationElementsFor(WebServerFeatureDescriptor.EXTENSION_ID);
List<DBWFeatureSet> features = new ArrayList<>();
for (IConfigurationElement ext : extConfigs) {
if (TAG_FEATURE.equals(ext.getName())) {
features.add(
new WebServerFeatureDescriptor(ext));
}
}
this.serverFeatures = features
.stream()
.map(DBWFeatureSet::getId)
.toArray(String[]::new);
}

public String[] getServerFeatures() {
return serverFeatures;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ type ServerConfig {

enabledFeatures: [ID!]!
disabledBetaFeatures: [ID!] @since(version: "24.0.5")
serverFeatures: [ID!] @since(version: "24.3.0")
enabledAuthProviders: [ID!]!
supportedLanguages: [ ServerLanguage! ]!
services: [ WebServiceConfig ]
Expand Down
Loading