Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
70f9d032
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70f9d032
编写于
12月 20, 2016
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Datasource jobs refactoring (events processing)
上级
0d0d455b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
75 addition
and
117 deletion
+75
-117
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
.../src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
+43
-5
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java
...ore/src/org/jkiss/dbeaver/registry/RegistryConstants.java
+10
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/ConnectJob.java
...r.core/src/org/jkiss/dbeaver/runtime/jobs/ConnectJob.java
+6
-8
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/DisconnectJob.java
...ore/src/org/jkiss/dbeaver/runtime/jobs/DisconnectJob.java
+5
-5
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/EventProcessorJob.java
...src/org/jkiss/dbeaver/runtime/jobs/EventProcessorJob.java
+0
-87
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/ConnectionWizard.java
...jkiss/dbeaver/ui/dialogs/connection/ConnectionWizard.java
+0
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditShellCommandsDialogPage.java
...er/ui/dialogs/connection/EditShellCommandsDialogPage.java
+11
-9
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
浏览文件 @
70f9d032
...
...
@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import
org.jkiss.dbeaver.model.app.DBPPlatform
;
import
org.jkiss.dbeaver.model.connection.DBPClientHome
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionEventType
;
import
org.jkiss.dbeaver.model.data.DBDDataFormatterProfile
;
import
org.jkiss.dbeaver.model.data.DBDPreferences
;
import
org.jkiss.dbeaver.model.data.DBDValueHandler
;
...
...
@@ -42,16 +43,14 @@ import org.jkiss.dbeaver.model.net.DBWHandlerType;
import
org.jkiss.dbeaver.model.net.DBWNetworkHandler
;
import
org.jkiss.dbeaver.model.net.DBWTunnel
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertySource
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressListener
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress
;
import
org.jkiss.dbeaver.model.runtime.*
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.model.virtual.DBVModel
;
import
org.jkiss.dbeaver.registry.driver.DriverDescriptor
;
import
org.jkiss.dbeaver.registry.formatter.DataFormatterProfile
;
import
org.jkiss.dbeaver.runtime.TasksJob
;
import
org.jkiss.dbeaver.runtime.properties.PropertyCollector
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
import
org.jkiss.dbeaver.ui.actions.datasource.DataSourceHandler
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -651,6 +650,8 @@ public class DataSourceDescriptor
}
}
processEvents
(
monitor
,
DBPConnectionEventType
.
BEFORE_CONNECT
);
tunnelConnectionInfo
=
null
;
try
{
// Handle tunnel
...
...
@@ -695,6 +696,8 @@ public class DataSourceDescriptor
connectTime
=
new
Date
();
loginDate
=
connectTime
;
processEvents
(
monitor
,
DBPConnectionEventType
.
AFTER_CONNECT
);
if
(
reflect
)
{
getRegistry
().
notifyDataSourceListeners
(
new
DBPEvent
(
DBPEvent
.
Action
.
OBJECT_UPDATE
,
...
...
@@ -748,6 +751,33 @@ public class DataSourceDescriptor
}
private
void
processEvents
(
DBRProgressMonitor
monitor
,
DBPConnectionEventType
eventType
)
{
DBPConnectionConfiguration
info
=
getActualConnectionConfiguration
();
DBRShellCommand
command
=
info
.
getEvent
(
eventType
);
if
(
command
!=
null
&&
command
.
isEnabled
())
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
info
.
getProperties
().
entrySet
())
{
variables
.
put
(
CommonUtils
.
toString
(
entry
.
getKey
()),
entry
.
getValue
());
}
variables
.
put
(
RegistryConstants
.
VARIABLE_HOST
,
info
.
getHostName
());
variables
.
put
(
RegistryConstants
.
VARIABLE_PORT
,
info
.
getHostPort
());
variables
.
put
(
RegistryConstants
.
VARIABLE_SERVER
,
info
.
getServerName
());
variables
.
put
(
RegistryConstants
.
VARIABLE_DATABASE
,
info
.
getDatabaseName
());
variables
.
put
(
RegistryConstants
.
VARIABLE_USER
,
info
.
getUserName
());
variables
.
put
(
RegistryConstants
.
VARIABLE_PASSWORD
,
info
.
getUserPassword
());
variables
.
put
(
RegistryConstants
.
VARIABLE_URL
,
info
.
getUrl
());
final
DBRProcessDescriptor
processDescriptor
=
new
DBRProcessDescriptor
(
command
,
variables
);
monitor
.
subTask
(
"Execute process "
+
processDescriptor
.
getName
());
DBUserInterface
.
getInstance
().
executeProcess
(
processDescriptor
);
if
(
command
.
isWaitProcessFinish
())
{
processDescriptor
.
waitFor
();
}
addChildProcess
(
processDescriptor
);
}
}
@Override
public
boolean
disconnect
(
final
DBRProgressMonitor
monitor
)
throws
DBException
...
...
@@ -812,7 +842,11 @@ public class DataSourceDescriptor
}
}
monitor
.
beginTask
(
"Disconnect from '"
+
getName
()
+
"'"
,
4
);
monitor
.
beginTask
(
"Disconnect from '"
+
getName
()
+
"'"
,
6
);
processEvents
(
monitor
,
DBPConnectionEventType
.
BEFORE_DISCONNECT
);
monitor
.
worked
(
1
);
// Close datasource
monitor
.
subTask
(
"Close connection"
);
...
...
@@ -834,6 +868,10 @@ public class DataSourceDescriptor
}
monitor
.
worked
(
1
);
processEvents
(
monitor
,
DBPConnectionEventType
.
AFTER_DISCONNECT
);
monitor
.
worked
(
1
);
monitor
.
done
();
// Terminate child processes
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java
浏览文件 @
70f9d032
...
...
@@ -22,6 +22,16 @@ package org.jkiss.dbeaver.registry;
*/
public
class
RegistryConstants
{
// Process parameters constants
public
static
final
String
VARIABLE_HOST
=
"host"
;
public
static
final
String
VARIABLE_PORT
=
"port"
;
public
static
final
String
VARIABLE_SERVER
=
"server"
;
public
static
final
String
VARIABLE_DATABASE
=
"database"
;
public
static
final
String
VARIABLE_USER
=
"user"
;
public
static
final
String
VARIABLE_PASSWORD
=
"password"
;
public
static
final
String
VARIABLE_URL
=
"url"
;
public
static
final
String
DRIVERS_FILE_NAME
=
"drivers.xml"
;
//$NON-NLS-1$
public
static
final
String
CONNECTION_TYPES_FILE_NAME
=
"connection-types.xml"
;
//$NON-NLS-1$
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/ConnectJob.java
浏览文件 @
70f9d032
...
...
@@ -22,10 +22,10 @@ import org.eclipse.core.runtime.Status;
import
org.eclipse.osgi.util.NLS
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionEventType
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
/**
...
...
@@ -33,7 +33,7 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
* Always returns OK status.
* To get real status use getConectStatus.
*/
public
class
ConnectJob
extends
EventProcessor
Job
public
class
ConnectJob
extends
Abstract
Job
{
private
static
final
Log
log
=
Log
.
getLog
(
ConnectJob
.
class
);
...
...
@@ -42,12 +42,14 @@ public class ConnectJob extends EventProcessorJob
protected
boolean
reflect
=
true
;
protected
Throwable
connectError
;
protected
IStatus
connectStatus
;
protected
final
DBPDataSourceContainer
container
;
public
ConnectJob
(
DataSourceDescriptor
container
)
{
super
(
NLS
.
bind
(
CoreMessages
.
runtime_jobs_connect_name
,
container
.
getName
())
,
container
);
super
(
NLS
.
bind
(
CoreMessages
.
runtime_jobs_connect_name
,
container
.
getName
()));
setUser
(
true
);
this
.
container
=
container
;
}
public
IStatus
getConnectStatus
()
{
...
...
@@ -68,8 +70,6 @@ public class ConnectJob extends EventProcessorJob
connectThread
.
setName
(
NLS
.
bind
(
CoreMessages
.
runtime_jobs_connect_thread_name
,
container
.
getName
()));
}
processEvents
(
DBPConnectionEventType
.
BEFORE_CONNECT
);
try
{
container
.
connect
(
monitor
,
initialize
,
reflect
);
}
finally
{
...
...
@@ -79,8 +79,6 @@ public class ConnectJob extends EventProcessorJob
}
}
processEvents
(
DBPConnectionEventType
.
AFTER_CONNECT
);
connectStatus
=
Status
.
OK_STATUS
;
}
catch
(
Throwable
ex
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/DisconnectJob.java
浏览文件 @
70f9d032
...
...
@@ -22,7 +22,7 @@ import org.eclipse.core.runtime.Status;
import
org.eclipse.osgi.util.NLS
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.
connection.DBPConnectionEventType
;
import
org.jkiss.dbeaver.model.
runtime.AbstractJob
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
...
...
@@ -31,14 +31,16 @@ import org.jkiss.dbeaver.utils.GeneralUtils;
* Always returns OK status.
* To get real status use getConectStatus.
*/
public
class
DisconnectJob
extends
EventProcessor
Job
public
class
DisconnectJob
extends
Abstract
Job
{
private
IStatus
connectStatus
;
protected
final
DBPDataSourceContainer
container
;
public
DisconnectJob
(
DBPDataSourceContainer
container
)
{
super
(
NLS
.
bind
(
CoreMessages
.
runtime_jobs_disconnect_name
,
container
.
getName
())
,
container
);
super
(
NLS
.
bind
(
CoreMessages
.
runtime_jobs_disconnect_name
,
container
.
getName
()));
setUser
(
true
);
this
.
container
=
container
;
}
public
IStatus
getConnectStatus
()
{
...
...
@@ -49,9 +51,7 @@ public class DisconnectJob extends EventProcessorJob
protected
IStatus
run
(
DBRProgressMonitor
monitor
)
{
try
{
processEvents
(
DBPConnectionEventType
.
BEFORE_DISCONNECT
);
container
.
disconnect
(
monitor
);
processEvents
(
DBPConnectionEventType
.
AFTER_DISCONNECT
);
connectStatus
=
Status
.
OK_STATUS
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/jobs/EventProcessorJob.java
已删除
100644 → 0
浏览文件 @
0d0d455b
/*
* 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.runtime.jobs
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBPDataSourceContainer
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionEventType
;
import
org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor
;
import
org.jkiss.dbeaver.model.runtime.DBRShellCommand
;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.model.runtime.AbstractJob
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Event processor job
*/
public
abstract
class
EventProcessorJob
extends
AbstractJob
{
private
static
final
Log
log
=
Log
.
getLog
(
EventProcessorJob
.
class
);
public
static
final
String
VARIABLE_HOST
=
"host"
;
public
static
final
String
VARIABLE_PORT
=
"port"
;
public
static
final
String
VARIABLE_SERVER
=
"server"
;
public
static
final
String
VARIABLE_DATABASE
=
"database"
;
public
static
final
String
VARIABLE_USER
=
"user"
;
public
static
final
String
VARIABLE_PASSWORD
=
"password"
;
public
static
final
String
VARIABLE_URL
=
"url"
;
protected
final
DBPDataSourceContainer
container
;
protected
EventProcessorJob
(
String
name
,
DBPDataSourceContainer
container
)
{
super
(
name
);
this
.
container
=
container
;
}
protected
void
processEvents
(
DBPConnectionEventType
eventType
)
{
DBPConnectionConfiguration
info
=
container
.
getActualConnectionConfiguration
();
DBRShellCommand
command
=
info
.
getEvent
(
eventType
);
if
(
command
!=
null
&&
command
.
isEnabled
())
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
info
.
getProperties
().
entrySet
())
{
variables
.
put
(
CommonUtils
.
toString
(
entry
.
getKey
()),
entry
.
getValue
());
}
variables
.
put
(
VARIABLE_HOST
,
info
.
getHostName
());
variables
.
put
(
VARIABLE_PORT
,
info
.
getHostPort
());
variables
.
put
(
VARIABLE_SERVER
,
info
.
getServerName
());
variables
.
put
(
VARIABLE_DATABASE
,
info
.
getDatabaseName
());
variables
.
put
(
VARIABLE_USER
,
info
.
getUserName
());
variables
.
put
(
VARIABLE_PASSWORD
,
info
.
getUserPassword
());
variables
.
put
(
VARIABLE_URL
,
info
.
getUrl
());
final
DBRProcessDescriptor
processDescriptor
=
new
DBRProcessDescriptor
(
command
,
variables
);
DBUserInterface
.
getInstance
().
executeProcess
(
processDescriptor
);
if
(
command
.
isWaitProcessFinish
())
{
processDescriptor
.
waitFor
();
}
if
(
container
instanceof
DataSourceDescriptor
)
{
((
DataSourceDescriptor
)
container
).
addChildProcess
(
processDescriptor
);
}
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/ConnectionWizard.java
浏览文件 @
70f9d032
...
...
@@ -231,9 +231,6 @@ public abstract class ConnectionWizard extends Wizard implements INewWizard {
if
(
dataSource
==
null
)
{
throw
new
DBException
(
CoreMessages
.
editors_sql_status_not_connected_to_database
);
}
// monitor.subTask("Initialize connection");
// dataSource.initialize(monitor);
// monitor.worked(1);
monitor
.
subTask
(
CoreMessages
.
dialog_connection_wizard_start_connection_monitor_subtask_test
);
DBPDataSourceInfo
info
=
dataSource
.
getInfo
();
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/connection/EditShellCommandsDialogPage.java
浏览文件 @
70f9d032
...
...
@@ -29,7 +29,7 @@ import org.jkiss.dbeaver.core.CoreMessages;
import
org.jkiss.dbeaver.model.connection.DBPConnectionEventType
;
import
org.jkiss.dbeaver.model.runtime.DBRShellCommand
;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.r
untime.jobs.EventProcessorJob
;
import
org.jkiss.dbeaver.r
egistry.RegistryConstants
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
...
...
@@ -155,13 +155,13 @@ public class EditShellCommandsDialogPage extends ActiveWizardPage<ConnectionWiza
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
gd
.
horizontalSpan
=
2
;
infoLabel
.
setLayoutData
(
gd
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_HOST
,
"target host"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_PORT
,
"target port"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_SERVER
,
"target server name"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_DATABASE
,
"target database"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_USER
,
"user name"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_PASSWORD
,
"password (plain)"
);
addVariableLegend
(
helpGroup
,
EventProcessorJob
.
VARIABLE_URL
,
"JDBC URL"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_HOST
,
"target host"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_PORT
,
"target port"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_SERVER
,
"target server name"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_DATABASE
,
"target database"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_USER
,
"user name"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_PASSWORD
,
"password (plain)"
);
addVariableLegend
(
helpGroup
,
RegistryConstants
.
VARIABLE_URL
,
"JDBC URL"
);
}
selectEventType
(
null
);
...
...
@@ -209,7 +209,9 @@ public class EditShellCommandsDialogPage extends ActiveWizardPage<ConnectionWiza
command
.
setCommand
(
commandText
.
getText
());
}
else
{
TableItem
item
=
getEventItem
(
eventType
);
command
.
setEnabled
(
item
.
getChecked
());
if
(
item
!=
null
)
{
command
.
setEnabled
(
item
.
getChecked
());
}
command
.
setShowProcessPanel
(
showProcessCheck
.
getSelection
());
command
.
setWaitProcessFinish
(
waitFinishCheck
.
getSelection
());
command
.
setTerminateAtDisconnect
(
terminateCheck
.
getSelection
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录