Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
81baaa26
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,发现更多精彩内容 >>
提交
81baaa26
编写于
12月 21, 2016
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Datasource origins
上级
cb79fc9f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
97 addition
and
17 deletion
+97
-17
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
.../src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
+15
-7
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
...core/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
+51
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
...re/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
+31
-10
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
浏览文件 @
81baaa26
...
...
@@ -112,6 +112,8 @@ public class DataSourceDescriptor
@NotNull
private
final
DBPDataSourceRegistry
registry
;
@NotNull
private
final
DataSourceOrigin
origin
;
@NotNull
private
DriverDescriptor
driver
;
@NotNull
private
DBPConnectionConfiguration
connectionInfo
;
...
...
@@ -138,8 +140,6 @@ public class DataSourceDescriptor
private
final
List
<
DBPDataSourceUser
>
users
=
new
ArrayList
<>();
private
boolean
provided
;
private
volatile
boolean
connectFailed
=
false
;
private
volatile
Date
connectTime
=
null
;
private
volatile
boolean
disposed
=
false
;
...
...
@@ -155,8 +155,19 @@ public class DataSourceDescriptor
@NotNull
String
id
,
@NotNull
DriverDescriptor
driver
,
@NotNull
DBPConnectionConfiguration
connectionInfo
)
{
this
(
registry
,
((
DataSourceRegistry
)
registry
).
getDefaultOrigin
(),
id
,
driver
,
connectionInfo
);
}
DataSourceDescriptor
(
@NotNull
DBPDataSourceRegistry
registry
,
@NotNull
DataSourceOrigin
origin
,
@NotNull
String
id
,
@NotNull
DriverDescriptor
driver
,
@NotNull
DBPConnectionConfiguration
connectionInfo
)
{
this
.
registry
=
registry
;
this
.
origin
=
origin
;
this
.
id
=
id
;
this
.
driver
=
driver
;
this
.
connectionInfo
=
connectionInfo
;
...
...
@@ -168,6 +179,7 @@ public class DataSourceDescriptor
public
DataSourceDescriptor
(
@NotNull
DataSourceDescriptor
source
)
{
this
.
registry
=
source
.
registry
;
this
.
origin
=
source
.
origin
;
this
.
id
=
source
.
id
;
this
.
name
=
source
.
name
;
this
.
description
=
source
.
description
;
...
...
@@ -512,11 +524,7 @@ public class DataSourceDescriptor
@Override
public
boolean
isProvided
()
{
return
provided
;
}
public
void
setProvided
(
boolean
provided
)
{
this
.
provided
=
provided
;
return
!
origin
.
isDefault
();
}
@Override
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
0 → 100644
浏览文件 @
81baaa26
/*
* 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.registry
;
import
java.io.File
;
/**
* DataSourceOrigin
*/
class
DataSourceOrigin
{
private
final
File
sourceFile
;
private
final
boolean
isDefault
;
public
DataSourceOrigin
(
File
sourceFile
,
boolean
isDefault
)
{
this
.
sourceFile
=
sourceFile
;
this
.
isDefault
=
isDefault
;
}
public
String
getName
()
{
return
sourceFile
.
getName
();
}
public
boolean
isDefault
()
{
return
isDefault
;
}
public
File
getSourceFile
()
{
return
sourceFile
;
}
@Override
public
String
toString
()
{
return
sourceFile
.
getAbsolutePath
();
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
浏览文件 @
81baaa26
...
...
@@ -85,6 +85,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private
final
DBPPlatform
platform
;
private
final
IProject
project
;
private
final
Map
<
File
,
DataSourceOrigin
>
origins
=
new
HashMap
<>();
private
final
List
<
DataSourceDescriptor
>
dataSources
=
new
ArrayList
<>();
private
final
List
<
DBPEventListener
>
dataSourceListeners
=
new
ArrayList
<>();
private
final
List
<
DataSourceFolder
>
dataSourceFolders
=
new
ArrayList
<>();
...
...
@@ -144,6 +145,20 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
}
}
DataSourceOrigin
getDefaultOrigin
()
{
synchronized
(
origins
)
{
for
(
DataSourceOrigin
origin
:
origins
.
values
())
{
if
(
origin
.
isDefault
())
{
return
origin
;
}
}
IFile
defFile
=
project
.
getFile
(
CONFIG_FILE_NAME
);
DataSourceOrigin
origin
=
new
DataSourceOrigin
(
defFile
.
getLocation
().
toFile
(),
true
);
origins
.
put
(
origin
.
getSourceFile
(),
origin
);
return
origin
;
}
}
@NotNull
public
DBPPlatform
getPlatform
()
{
return
platform
;
...
...
@@ -462,12 +477,20 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private
void
loadDataSources
(
File
fromFile
,
boolean
refresh
,
ParseResults
parseResults
)
{
boolean
extraConfig
=
!
fromFile
.
getName
().
equalsIgnoreCase
(
CONFIG_FILE_NAME
);
DataSourceOrigin
origin
;
synchronized
(
origins
)
{
origin
=
origins
.
get
(
fromFile
);
if
(
origin
==
null
)
{
origin
=
new
DataSourceOrigin
(
fromFile
,
!
extraConfig
);
origins
.
put
(
fromFile
,
origin
);
}
}
if
(!
fromFile
.
exists
())
{
return
;
}
boolean
extraConfig
=
!
fromFile
.
getName
().
equalsIgnoreCase
(
CONFIG_FILE_NAME
);
try
(
InputStream
is
=
new
FileInputStream
(
fromFile
))
{
loadDataSources
(
is
,
extraConfig
,
refresh
,
parseResults
);
loadDataSources
(
is
,
origin
,
refresh
,
parseResults
);
}
catch
(
DBException
ex
)
{
log
.
warn
(
"Error loading datasource config from "
+
fromFile
.
getAbsolutePath
(),
ex
);
}
catch
(
IOException
ex
)
{
...
...
@@ -475,12 +498,12 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
}
}
private
void
loadDataSources
(
InputStream
is
,
boolean
extraConfig
,
boolean
refresh
,
ParseResults
parseResults
)
private
void
loadDataSources
(
InputStream
is
,
DataSourceOrigin
origin
,
boolean
refresh
,
ParseResults
parseResults
)
throws
DBException
,
IOException
{
SAXReader
parser
=
new
SAXReader
(
is
);
try
{
final
DataSourcesParser
dsp
=
new
DataSourcesParser
(
extraConfig
,
refresh
,
parseResults
);
final
DataSourcesParser
dsp
=
new
DataSourcesParser
(
origin
,
refresh
,
parseResults
);
parser
.
parse
(
dsp
);
}
catch
(
XMLException
ex
)
{
...
...
@@ -878,7 +901,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private
class
DataSourcesParser
implements
SAXListener
{
DataSourceDescriptor
curDataSource
;
boolean
extraConfig
;
DataSourceOrigin
origin
;
boolean
refresh
;
boolean
isDescription
=
false
;
DBRShellCommand
curCommand
=
null
;
...
...
@@ -888,9 +911,9 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private
ParseResults
parseResults
;
private
boolean
passwordReadCanceled
=
false
;
private
DataSourcesParser
(
boolean
extraConfig
,
boolean
refresh
,
ParseResults
parseResults
)
private
DataSourcesParser
(
DataSourceOrigin
origin
,
boolean
refresh
,
ParseResults
parseResults
)
{
this
.
extraConfig
=
extraConfig
;
this
.
origin
=
origin
;
this
.
refresh
=
refresh
;
this
.
parseResults
=
parseResults
;
}
...
...
@@ -943,6 +966,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
if
(
newDataSource
)
{
curDataSource
=
new
DataSourceDescriptor
(
DataSourceRegistry
.
this
,
origin
,
id
,
driver
,
new
DBPConnectionConfiguration
());
...
...
@@ -952,9 +976,6 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
curDataSource
.
getConnectionConfiguration
().
setHandlers
(
Collections
.<
DBWHandlerConfiguration
>
emptyList
());
curDataSource
.
clearFilters
();
}
if
(
extraConfig
)
{
curDataSource
.
setProvided
(
true
);
}
curDataSource
.
setName
(
name
);
try
{
String
createDate
=
atts
.
getValue
(
RegistryConstants
.
ATTR_CREATE_DATE
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录