提交 a514ae77 编写于 作者: S Serge Rider

Application model

上级 fb857b02
......@@ -41,6 +41,9 @@ import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.application.rpc.DBeaverInstanceServer;
import org.jkiss.dbeaver.core.application.rpc.IInstanceController;
import org.jkiss.dbeaver.core.application.rpc.InstanceClient;
import org.jkiss.dbeaver.model.app.DBAClientSecurity;
import org.jkiss.dbeaver.model.app.DBPApplication;
import org.jkiss.dbeaver.model.impl.app.DefaultClientSecurity;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.SystemVariablesResolver;
import org.jkiss.utils.ArrayUtils;
......@@ -63,7 +66,7 @@ import java.util.List;
/**
* This class controls all aspects of the application's execution
*/
public class DBeaverApplication implements IApplication {
public class DBeaverApplication implements IApplication, DBPApplication {
public static final String APPLICATION_PLUGIN_ID = "org.jkiss.dbeaver.core.application";
public static final String DBEAVER_DEFAULT_DIR = ".dbeaver"; //$NON-NLS-1$
......@@ -176,7 +179,7 @@ public class DBeaverApplication implements IApplication {
final Runtime runtime = Runtime.getRuntime();
// Init Core plugin and mark it as standalone version
DBeaverCore.setStandalone(true);
DBeaverCore.setApplication(this);
initDebugWriter();
......@@ -368,6 +371,17 @@ public class DBeaverApplication implements IApplication {
}
}
@Override
public boolean isStandalone() {
return true;
}
@NotNull
@Override
public DBAClientSecurity getClientSecurity() {
return DefaultClientSecurity.INSTANCE;
}
private class ProxyPrintStream extends OutputStream {
private final OutputStream debugWriter;
private final OutputStream stdOut;
......
......@@ -30,6 +30,7 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.app.DBACertificateStorage;
import org.jkiss.dbeaver.model.app.DBPApplication;
import org.jkiss.dbeaver.model.app.DBPPlatform;
import org.jkiss.dbeaver.model.app.DBPProjectManager;
import org.jkiss.dbeaver.model.data.DBDRegistry;
......@@ -77,8 +78,12 @@ public class DBeaverCore implements DBPPlatform {
public static final String TEMP_PROJECT_NAME = ".dbeaver-temp"; //$NON-NLS-1$
private static final DBPApplication DEFAULT_APPLICATION = new EclipseApplication();
static DBeaverCore instance;
private static boolean standalone = false;
@NotNull
private static DBPApplication application = DEFAULT_APPLICATION;
private static volatile boolean isClosing = false;
private File tempFolder;
......@@ -140,12 +145,12 @@ public class DBeaverCore implements DBPPlatform {
public static boolean isStandalone()
{
return standalone;
return application.isStandalone();
}
public static void setStandalone(boolean flag)
public static void setApplication(@NotNull DBPApplication app)
{
standalone = flag;
application = app;
}
public static boolean isClosing()
......@@ -295,9 +300,10 @@ public class DBeaverCore implements DBPPlatform {
tempFolder = null;
}
DBeaverCore.application = DEFAULT_APPLICATION;
DBeaverCore.instance = null;
DBeaverCore.disposed = true;
System.gc();
log.debug("Shutdown completed in " + (System.currentTimeMillis() - startTime) + "ms");
}
......@@ -319,6 +325,12 @@ public class DBeaverCore implements DBPPlatform {
return localSystem;
}
@NotNull
@Override
public DBPApplication getApplication() {
return application;
}
@NotNull
@Override
public DBNModel getNavigatorModel()
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 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.core;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.app.DBAClientSecurity;
import org.jkiss.dbeaver.model.app.DBPApplication;
import org.jkiss.dbeaver.model.impl.app.DefaultClientSecurity;
/**
* EclipseApplication
*/
class EclipseApplication implements DBPApplication {
@Override
public boolean isStandalone() {
return false;
}
@NotNull
@Override
public DBAClientSecurity getClientSecurity() {
return DefaultClientSecurity.INSTANCE;
}
}
......@@ -25,6 +25,9 @@ import org.jkiss.code.NotNull;
*/
public interface DBPApplication
{
boolean isStandalone();
@NotNull
DBAClientSecurity getClientSecurity();
}
......@@ -37,6 +37,9 @@ import java.util.List;
*/
public interface DBPPlatform
{
@NotNull
DBPApplication getApplication();
@NotNull
DBNModel getNavigatorModel();
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 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.model.impl.app;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBACertificateStorage;
import org.jkiss.dbeaver.model.app.DBAClientSecurity;
import java.io.*;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
/**
* DefaultClientSecurity
*/
public class DefaultClientSecurity implements DBAClientSecurity {
public static DefaultClientSecurity INSTANCE = new DefaultClientSecurity();
@Override
public boolean useSecurePreferences() {
return false;
}
@Override
public ISecurePreferences getSecurePreferences() {
return SecurePreferencesFactory.getDefault();
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册