Search in sources :

Example 1 with IPluginService

use of org.jkiss.dbeaver.runtime.IPluginService in project dbeaver by dbeaver.

the class DBeaverCore method dispose.

public synchronized void dispose() {
    long startTime = System.currentTimeMillis();
    log.debug("Shutdown Core...");
    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();
    // It is a part of UI
    if (this.navigatorModel != null) {
        this.navigatorModel.dispose();
    // this.navigatorModel = null;
    }
    // It will close all open connections
    if (this.projectRegistry != null) {
        this.projectRegistry.dispose();
        this.projectRegistry = null;
    }
    if (this.qmLogWriter != null) {
        this.queryManager.unregisterMetaListener(qmLogWriter);
        this.qmLogWriter.dispose();
        this.qmLogWriter = null;
    }
    if (this.queryManager != null) {
        this.queryManager.dispose();
    // queryManager = null;
    }
    DataSourceProviderRegistry.getInstance().dispose();
    if (isStandalone() && workspace != null) {
        try {
            IProgressMonitor monitor = new NullProgressMonitor();
            workspace.save(true, monitor);
        } catch (CoreException ex) {
            // $NON-NLS-1$
            log.error("Can't save workspace", ex);
        }
    }
    // Remove temp folder
    if (tempFolder != null) {
        if (!ContentUtils.deleteFileRecursive(tempFolder)) {
            log.warn("Can't delete temp folder '" + tempFolder.getAbsolutePath() + "'");
        }
        tempFolder = null;
    }
    DBeaverCore.application = DEFAULT_APPLICATION;
    DBeaverCore.instance = null;
    DBeaverCore.disposed = true;
    System.gc();
    log.debug("Shutdown completed in " + (System.currentTimeMillis() - startTime) + "ms");
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IPluginService(org.jkiss.dbeaver.runtime.IPluginService) CoreException(org.eclipse.core.runtime.CoreException) DBException(org.jkiss.dbeaver.DBException) AccessDeniedException(java.nio.file.AccessDeniedException) IOException(java.io.IOException)

Example 2 with IPluginService

use of org.jkiss.dbeaver.runtime.IPluginService in project dbeaver by dbeaver.

the class DBeaverCore method initialize.

private void initialize() {
    long startTime = System.currentTimeMillis();
    log.debug("Initialize Core...");
    DBPPreferenceStore prefsStore = getGlobalPreferenceStore();
    // ' Global pref events forwarder
    prefsStore.addPropertyChangeListener(new DBPPreferenceListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            // Forward event to all data source preferences
            for (DataSourceDescriptor ds : DataSourceRegistry.getAllDataSources()) {
                ds.getPreferenceStore().firePropertyChangeEvent(event.getProperty(), event.getOldValue(), event.getNewValue());
            }
        }
    });
    // Register properties adapter
    this.workspace = ResourcesPlugin.getWorkspace();
    this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
    {
        this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.getDefault());
        if (this.language == null) {
            log.debug("Language for locale '" + Locale.getDefault() + "' not found. Use default.");
            this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.ENGLISH);
        }
    }
    QMUtils.initApplication(this);
    this.queryManager = new QMControllerImpl();
    this.qmLogWriter = new QMLogFileWriter();
    this.queryManager.registerMetaListener(qmLogWriter);
    // Init default network settings
    Authenticator.setDefault(new GlobalProxyAuthenticator());
    ProxySelector.setDefault(new GlobalProxySelector(ProxySelector.getDefault()));
    this.certificateStorage = new DefaultCertificateStorage(new File(DBeaverActivator.getInstance().getStateLocation().toFile(), "security"));
    // Init project registry
    this.projectRegistry = new ProjectRegistry(workspace);
    // Projects registry
    initializeProjects();
    // Navigator model
    this.navigatorModel = new DBNModel(this);
    this.navigatorModel.initialize();
    // Activate plugin services
    for (IPluginService pluginService : PluginServiceRegistry.getInstance().getServices()) {
        try {
            pluginService.activateService();
            activatedServices.add(pluginService);
        } catch (Throwable e) {
            log.error("Error activating plugin service", e);
        }
    }
    // Keep-alive job
    new KeepAliveJob(this).scheduleMonitor();
    log.debug("Core initialized (" + (System.currentTimeMillis() - startTime) + "ms)");
}
Also used : DefaultCertificateStorage(org.jkiss.dbeaver.model.impl.app.DefaultCertificateStorage) QMControllerImpl(org.jkiss.dbeaver.runtime.qm.QMControllerImpl) QMLogFileWriter(org.jkiss.dbeaver.runtime.qm.QMLogFileWriter) KeepAliveJob(org.jkiss.dbeaver.runtime.jobs.KeepAliveJob) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel) GlobalProxySelector(org.jkiss.dbeaver.runtime.net.GlobalProxySelector) IPluginService(org.jkiss.dbeaver.runtime.IPluginService) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) OSDescriptor(org.jkiss.dbeaver.model.runtime.OSDescriptor) File(java.io.File) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 3 with IPluginService

use of org.jkiss.dbeaver.runtime.IPluginService in project dbeaver by serge-rider.

the class BasePlatformImpl method initialize.

protected void initialize() {
    log.debug("Initialize base platform...");
    DBPPreferenceStore prefsStore = getPreferenceStore();
    // Global pref events forwarder
    prefsStore.addPropertyChangeListener(event -> {
        // Forward event to all data source preferences
        for (DBPDataSourceContainer ds : DataSourceRegistry.getAllDataSources()) {
            ((AbstractPreferenceStore) ds.getPreferenceStore()).firePropertyChangeEvent(prefsStore, event.getProperty(), event.getOldValue(), event.getNewValue());
        }
    });
    this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
    {
        this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.getDefault());
        if (this.language == null) {
            log.debug("Language for locale '" + Locale.getDefault() + "' not found. Use default.");
            this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.ENGLISH);
        }
    }
    // Navigator model
    this.navigatorModel = new DBNModel(this, null);
    this.navigatorModel.initialize();
    // Activate plugin services
    for (IPluginService pluginService : PluginServiceRegistry.getInstance().getServices()) {
        try {
            pluginService.activateService();
            activatedServices.add(pluginService);
        } catch (Throwable e) {
            log.error("Error activating plugin service", e);
        }
    }
    // Keep-alive job
    new KeepAliveListenerJob(this).scheduleMonitor();
}
Also used : AbstractPreferenceStore(org.jkiss.dbeaver.model.impl.preferences.AbstractPreferenceStore) KeepAliveListenerJob(org.jkiss.dbeaver.runtime.jobs.KeepAliveListenerJob) IPluginService(org.jkiss.dbeaver.runtime.IPluginService) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) OSDescriptor(org.jkiss.dbeaver.model.runtime.OSDescriptor) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Aggregations

IPluginService (org.jkiss.dbeaver.runtime.IPluginService)3 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)2 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)2 OSDescriptor (org.jkiss.dbeaver.model.runtime.OSDescriptor)2 File (java.io.File)1 IOException (java.io.IOException)1 AccessDeniedException (java.nio.file.AccessDeniedException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 DBException (org.jkiss.dbeaver.DBException)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 DefaultCertificateStorage (org.jkiss.dbeaver.model.impl.app.DefaultCertificateStorage)1 AbstractPreferenceStore (org.jkiss.dbeaver.model.impl.preferences.AbstractPreferenceStore)1 DBPPreferenceListener (org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)1 KeepAliveJob (org.jkiss.dbeaver.runtime.jobs.KeepAliveJob)1 KeepAliveListenerJob (org.jkiss.dbeaver.runtime.jobs.KeepAliveListenerJob)1 GlobalProxySelector (org.jkiss.dbeaver.runtime.net.GlobalProxySelector)1 QMControllerImpl (org.jkiss.dbeaver.runtime.qm.QMControllerImpl)1 QMLogFileWriter (org.jkiss.dbeaver.runtime.qm.QMLogFileWriter)1