提交 111f684d 编写于 作者: J jurgen

Plugin services model

上级 cda3c12c
DBeaver features usage model
Data transfer DECIMAL(x,y) types convert.
Extract non-visual part to a separate plugin (preferences + editors)
RSV find/replace action
......
......@@ -21,6 +21,7 @@
-->
<plugin>
<extension-point id="org.jkiss.dbeaver.pluginService" name="Plugin service" schema="schema/org.jkiss.dbeaver.pluginService.exsd"/>
<extension-point id="org.jkiss.dbeaver.dataSourceProvider" name="DataSource provider" schema="schema/org.jkiss.dbeaver.dataSourceProvider.exsd"/>
<extension-point id="org.jkiss.dbeaver.databaseEditor" name="Custom Entity Editor" schema="schema/org.jkiss.dbeaver.databaseEditor.exsd"/>
<extension-point id="org.jkiss.dbeaver.dataTypeProvider" name="DataType provider" schema="schema/org.jkiss.dbeaver.dataTypeProvider.exsd"/>
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.jkiss.dbeaver.core" id="org.jkiss.dbeaver.pluginService" name="Plugin Service"/>
</appInfo>
<documentation>
Plugin Service
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="service" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="handler">
<complexType>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="label" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
<attribute name="type" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="secured" type="boolean">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="handlerClass" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.jkiss.dbeaver.model.net.DBWNetworkHandler"/>
</appInfo>
</annotation>
</attribute>
<attribute name="uiClass" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.jkiss.dbeaver.ui.IObjectPropertyConfigurator"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
......@@ -24,6 +24,8 @@ import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.registry.PluginServiceRegistry;
import org.jkiss.dbeaver.runtime.IPluginService;
import org.jkiss.dbeaver.runtime.net.GlobalProxyAuthenticator;
import org.jkiss.dbeaver.runtime.net.GlobalProxySelector;
import org.jkiss.dbeaver.model.navigator.DBNModel;
......@@ -67,6 +69,8 @@ public class DBeaverCore implements DBPApplication {
private QMLogFileWriter qmLogWriter;
private ProjectRegistry projectRegistry;
private final List<IPluginService> activatedServices = new ArrayList<IPluginService>();
private static boolean disposed = false;
public static DBeaverCore getInstance()
......@@ -156,8 +160,6 @@ public class DBeaverCore implements DBPApplication {
this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
this.queryManager = new QMControllerImpl();
this.qmLogWriter = new QMLogFileWriter();
this.queryManager.registerMetaListener(qmLogWriter);
......@@ -168,7 +170,6 @@ public class DBeaverCore implements DBPApplication {
// Init project registry
this.projectRegistry = new ProjectRegistry(workspace);
this.projectRegistry.loadExtensions(extensionRegistry);
// Projects registry
initializeProjects();
......@@ -176,6 +177,16 @@ public class DBeaverCore implements DBPApplication {
// Navigator model
this.navigatorModel = new DBNModel();
this.navigatorModel.initialize();
// Activate plugin services
for (IPluginService pluginService : PluginServiceRegistry.getInstance().getServices()) {
try {
pluginService.activateService();
activatedServices.add(pluginService);
} catch (Exception e) {
log.error("Error activating plugin service", e);
}
}
}
private void initializeProjects()
......@@ -219,6 +230,16 @@ public class DBeaverCore implements DBPApplication {
DBeaverCore.setClosing(true);
// Deactivate plugin services
for (IPluginService pluginService : activatedServices) {
try {
pluginService.deactivateService();
} catch (Exception e) {
log.error("Error deactivating plugin service", e);
}
}
activatedServices.clear();
// Dispose navigator model first
// It is a part of UI
if (this.navigatorModel != null) {
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.runtime.IPluginService;
import java.util.ArrayList;
import java.util.List;
public class PluginServiceRegistry
{
public static final String EXTENSION_ID = "org.jkiss.dbeaver.pluginService"; //$NON-NLS-1$
private static PluginServiceRegistry instance = null;
private class ServiceDescriptor extends AbstractDescriptor {
private final ObjectType type;
protected ServiceDescriptor(IConfigurationElement config) {
super(config);
type = new ObjectType(config.getAttribute(RegistryConstants.ATTR_CLASS));
}
}
public synchronized static PluginServiceRegistry getInstance()
{
if (instance == null) {
instance = new PluginServiceRegistry(Platform.getExtensionRegistry());
}
return instance;
}
private final List<IPluginService> services = new ArrayList<IPluginService>();
private PluginServiceRegistry(IExtensionRegistry registry)
{
IConfigurationElement[] extElements = registry.getConfigurationElementsFor(EXTENSION_ID);
for (IConfigurationElement ext : extElements) {
ServiceDescriptor serviceDescriptor = new ServiceDescriptor(ext);
try {
IPluginService pluginService = serviceDescriptor.type.createInstance(IPluginService.class);
services.add(pluginService);
} catch (DBException e) {
ServiceDescriptor.log.error("Can't create plugin service", e);
}
}
}
public List<IPluginService> getServices()
{
return services;
}
}
......@@ -56,6 +56,7 @@ public class ProjectRegistry {
public ProjectRegistry(IWorkspace workspace)
{
this.workspace = workspace;
loadExtensions(Platform.getExtensionRegistry());
}
public void loadExtensions(IExtensionRegistry registry)
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.runtime;
/**
* Plugin service.
* Activated/deactivated by DBeaver core on startup/shutdown.
*/
public interface IPluginService {
void activateService();
void deactivateService();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册