Skip to content

Commit

Permalink
dbeaver/dbeaver-vscode#45 server feature extension (#3075)
Browse files Browse the repository at this point in the history
* dbeaver/dbeaver-vscode#45 server feature extension

* dbeaver/dbeaver-vscode#45 review fix

---------

Co-authored-by: Alexey <[email protected]>
  • Loading branch information
alexander-skoblikov and Wroud authored Nov 26, 2024
1 parent ff2cc51 commit ea8605e
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 22 deletions.
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 check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureDescriptor.java#L40

[ at column 5 should be on the previous line.
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 check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java#L36

Missing a Javadoc comment.

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

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebServerFeatureRegistry.java#L36

static modifier out of order with the JLS suggestions.
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

0 comments on commit ea8605e

Please sign in to comment.