Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
f1243d58
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
f1243d58
编写于
10月 14, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Maven resolve context
Former-commit-id:
b05a35ec
上级
a5ca2871
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
215 addition
and
172 deletion
+215
-172
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDependencies.java
...org/jkiss/dbeaver/registry/driver/DriverDependencies.java
+7
-8
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
...c/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
+3
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
.../jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
+7
-7
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
...org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
+4
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
...s/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
+22
-19
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
...dbeaver/registry/driver/DriverLibraryMavenDependency.java
+3
-3
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryRepository.java
...kiss/dbeaver/registry/driver/DriverLibraryRepository.java
+2
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+11
-11
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
...rg/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
+20
-28
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenContextInfo.java
...rc/org/jkiss/dbeaver/registry/maven/MavenContextInfo.java
+6
-28
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+9
-8
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+7
-6
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
...iss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
+39
-40
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverContext.java
.../org/jkiss/dbeaver/model/connection/DBPDriverContext.java
+70
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
.../org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
+5
-5
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDependencies.java
浏览文件 @
f1243d58
...
@@ -20,8 +20,7 @@ package org.jkiss.dbeaver.registry.driver;
...
@@ -20,8 +20,7 @@ package org.jkiss.dbeaver.registry.driver;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.registry.maven.MavenContext
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -34,7 +33,7 @@ public class DriverDependencies implements DBPDriverDependencies
...
@@ -34,7 +33,7 @@ public class DriverDependencies implements DBPDriverDependencies
final
List
<
DependencyNode
>
rootNodes
=
new
ArrayList
<>();
final
List
<
DependencyNode
>
rootNodes
=
new
ArrayList
<>();
final
List
<
DBPDriverLibrary
>
libraryList
=
new
ArrayList
<>();
final
List
<
DBPDriverLibrary
>
libraryList
=
new
ArrayList
<>();
void
resolveDependencies
(
Maven
Context
context
,
Collection
<?
extends
DBPDriverLibrary
>
rootLibraries
)
throws
DBException
{
void
resolveDependencies
(
DBPDriver
Context
context
,
Collection
<?
extends
DBPDriverLibrary
>
rootLibraries
)
throws
DBException
{
try
{
try
{
{
{
rootNodes
.
clear
();
rootNodes
.
clear
();
...
@@ -44,7 +43,7 @@ public class DriverDependencies implements DBPDriverDependencies
...
@@ -44,7 +43,7 @@ public class DriverDependencies implements DBPDriverDependencies
DependencyNode
node
=
new
DependencyNode
(
null
,
library
);
DependencyNode
node
=
new
DependencyNode
(
null
,
library
);
libMap
.
put
(
node
.
library
.
getId
(),
node
.
library
);
libMap
.
put
(
node
.
library
.
getId
(),
node
.
library
);
resolveDependencies
(
context
.
getMonitor
()
,
node
,
libMap
);
resolveDependencies
(
context
,
node
,
libMap
);
rootNodes
.
add
(
node
);
rootNodes
.
add
(
node
);
}
}
libraryList
.
clear
();
libraryList
.
clear
();
...
@@ -86,9 +85,9 @@ public class DriverDependencies implements DBPDriverDependencies
...
@@ -86,9 +85,9 @@ public class DriverDependencies implements DBPDriverDependencies
}
}
}
}
private
void
resolveDependencies
(
DB
RProgressMonitor
monitor
,
DependencyNode
ownerNode
,
Map
<
String
,
DBPDriverLibrary
>
libMap
)
throws
IOException
{
private
void
resolveDependencies
(
DB
PDriverContext
context
,
DependencyNode
ownerNode
,
Map
<
String
,
DBPDriverLibrary
>
libMap
)
throws
IOException
{
ownerNode
.
library
.
resolve
(
monitor
);
ownerNode
.
library
.
resolve
(
context
);
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
ownerNode
.
library
.
getDependencies
(
monitor
);
Collection
<?
extends
DBPDriverLibrary
>
dependencies
=
ownerNode
.
library
.
getDependencies
(
context
);
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
if
(
dependencies
!=
null
&&
!
dependencies
.
isEmpty
())
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
for
(
DBPDriverLibrary
dep
:
dependencies
)
{
DependencyNode
node
=
new
DependencyNode
(
ownerNode
,
dep
);
DependencyNode
node
=
new
DependencyNode
(
ownerNode
,
dep
);
...
@@ -101,7 +100,7 @@ public class DriverDependencies implements DBPDriverDependencies
...
@@ -101,7 +100,7 @@ public class DriverDependencies implements DBPDriverDependencies
}
}
for
(
DependencyNode
node
:
ownerNode
.
dependencies
)
{
for
(
DependencyNode
node
:
ownerNode
.
dependencies
)
{
if
(!
node
.
duplicate
)
{
if
(!
node
.
duplicate
)
{
resolveDependencies
(
monitor
,
node
,
libMap
);
resolveDependencies
(
context
,
node
,
libMap
);
}
}
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverDescriptor.java
浏览文件 @
f1243d58
...
@@ -39,7 +39,7 @@ import org.jkiss.dbeaver.model.runtime.OSDescriptor;
...
@@ -39,7 +39,7 @@ import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceProviderDescriptor
;
import
org.jkiss.dbeaver.registry.DataSourceProviderDescriptor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.
registry.maven.Maven
Context
;
import
org.jkiss.dbeaver.
model.connection.DBPDriver
Context
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.AcceptLicenseDialog
;
import
org.jkiss.dbeaver.ui.dialogs.AcceptLicenseDialog
;
import
org.jkiss.dbeaver.ui.dialogs.driver.DriverDownloadDialog
;
import
org.jkiss.dbeaver.ui.dialogs.driver.DriverDownloadDialog
;
...
@@ -60,10 +60,10 @@ import java.util.*;
...
@@ -60,10 +60,10 @@ import java.util.*;
*/
*/
public
class
DriverDescriptor
extends
AbstractDescriptor
implements
DBPDriver
public
class
DriverDescriptor
extends
AbstractDescriptor
implements
DBPDriver
{
{
public
static
final
String
PROP_DRIVERS_LOCATION
=
"DRIVERS_LOCATION"
;
static
final
Log
log
=
Log
.
getLog
(
DriverDescriptor
.
class
);
static
final
Log
log
=
Log
.
getLog
(
DriverDescriptor
.
class
);
public
static
final
String
DRIVERS_FOLDER
=
"drivers"
;
//$NON-NLS-1$
public
static
final
String
DRIVERS_FOLDER
=
"drivers"
;
//$NON-NLS-1$
public
static
final
String
PROP_DRIVERS_LOCATION
=
"DRIVERS_LOCATION"
;
public
static
final
char
URL_GROUP_START
=
'{'
;
//$NON-NLS-1$
public
static
final
char
URL_GROUP_START
=
'{'
;
//$NON-NLS-1$
public
static
final
char
URL_GROUP_END
=
'}'
;
//$NON-NLS-1$
public
static
final
char
URL_GROUP_END
=
'}'
;
//$NON-NLS-1$
...
@@ -614,7 +614,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
...
@@ -614,7 +614,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
@Override
@Override
public
DBPDriverDependencies
resolveDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
public
DBPDriverDependencies
resolveDependencies
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
if
(
dependencies
==
null
)
{
if
(
dependencies
==
null
)
{
try
(
MavenContext
mavenContext
=
new
Maven
Context
(
monitor
))
{
try
(
DBPDriverContext
mavenContext
=
new
DBPDriver
Context
(
monitor
))
{
DriverDependencies
depsResolver
=
new
DriverDependencies
();
DriverDependencies
depsResolver
=
new
DriverDependencies
();
depsResolver
.
resolveDependencies
(
mavenContext
,
getDriverLibraries
());
depsResolver
.
resolveDependencies
(
mavenContext
,
getDriverLibraries
());
this
.
dependencies
=
depsResolver
;
this
.
dependencies
=
depsResolver
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryAbstract.java
浏览文件 @
f1243d58
...
@@ -21,8 +21,8 @@ import org.eclipse.core.runtime.IConfigurationElement;
...
@@ -21,8 +21,8 @@ import org.eclipse.core.runtime.IConfigurationElement;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
...
@@ -151,7 +151,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -151,7 +151,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
return
system
==
null
||
system
.
matches
(
DBeaverCore
.
getInstance
().
getLocalSystem
());
return
system
==
null
||
system
.
matches
(
DBeaverCore
.
getInstance
().
getLocalSystem
());
}
}
public
void
downloadLibraryFile
(
@NotNull
DB
RProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
public
void
downloadLibraryFile
(
@NotNull
DB
PDriverContext
context
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
{
final
File
localFile
=
getLocalFile
();
final
File
localFile
=
getLocalFile
();
if
(
localFile
==
null
)
{
if
(
localFile
==
null
)
{
...
@@ -167,7 +167,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -167,7 +167,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
}
}
}
}
String
externalURL
=
getExternalURL
(
monitor
);
String
externalURL
=
getExternalURL
(
context
);
if
(
externalURL
==
null
)
{
if
(
externalURL
==
null
)
{
throw
new
IOException
(
"Unresolved file reference: "
+
getPath
());
throw
new
IOException
(
"Unresolved file reference: "
+
getPath
());
}
}
...
@@ -185,7 +185,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -185,7 +185,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
if
(
bufferLength
<
50000
)
{
if
(
bufferLength
<
50000
)
{
bufferLength
=
50000
;
bufferLength
=
50000
;
}
}
monitor
.
beginTask
(
taskName
+
" - "
+
externalURL
,
contentLength
);
context
.
getMonitor
()
.
beginTask
(
taskName
+
" - "
+
externalURL
,
contentLength
);
boolean
success
=
false
;
boolean
success
=
false
;
try
(
final
OutputStream
outputStream
=
new
FileOutputStream
(
localFile
))
{
try
(
final
OutputStream
outputStream
=
new
FileOutputStream
(
localFile
))
{
try
(
final
InputStream
inputStream
=
connection
.
getInputStream
())
{
try
(
final
InputStream
inputStream
=
connection
.
getInputStream
())
{
...
@@ -193,7 +193,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -193,7 +193,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
byte
[]
buffer
=
new
byte
[
bufferLength
];
byte
[]
buffer
=
new
byte
[
bufferLength
];
int
totalRead
=
0
;
int
totalRead
=
0
;
for
(;;)
{
for
(;;)
{
if
(
monitor
.
isCanceled
())
{
if
(
context
.
getMonitor
()
.
isCanceled
())
{
throw
new
InterruptedException
();
throw
new
InterruptedException
();
}
}
//monitor.subTask(numberFormat.format(totalRead) + "/" + numberFormat.format(contentLength));
//monitor.subTask(numberFormat.format(totalRead) + "/" + numberFormat.format(contentLength));
...
@@ -203,7 +203,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -203,7 +203,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
break
;
break
;
}
}
outputStream
.
write
(
buffer
,
0
,
count
);
outputStream
.
write
(
buffer
,
0
,
count
);
monitor
.
worked
(
count
);
context
.
getMonitor
()
.
worked
(
count
);
totalRead
+=
count
;
totalRead
+=
count
;
}
}
}
}
...
@@ -213,7 +213,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
...
@@ -213,7 +213,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
log
.
warn
(
"Can't delete local driver file '"
+
localFile
.
getAbsolutePath
()
+
"'"
);
log
.
warn
(
"Can't delete local driver file '"
+
localFile
.
getAbsolutePath
()
+
"'"
);
}
}
}
}
monitor
.
done
();
context
.
getMonitor
()
.
done
();
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryLocal.java
浏览文件 @
f1243d58
...
@@ -23,8 +23,8 @@ import org.eclipse.core.runtime.Platform;
...
@@ -23,8 +23,8 @@ import org.eclipse.core.runtime.Platform;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
java.io.File
;
import
java.io.File
;
...
@@ -58,7 +58,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
...
@@ -58,7 +58,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
}
}
@Override
@Override
public
void
resolve
(
DB
RProgressMonitor
monitor
)
throws
IOException
{
public
void
resolve
(
DB
PDriverContext
context
)
throws
IOException
{
// do nothing
// do nothing
}
}
...
@@ -68,7 +68,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
...
@@ -68,7 +68,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
@Nullable
@Nullable
@Override
@Override
public
String
getExternalURL
(
DB
RProgressMonitor
monitor
)
{
public
String
getExternalURL
(
DB
PDriverContext
context
)
{
return
null
;
return
null
;
}
}
...
@@ -115,7 +115,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
...
@@ -115,7 +115,7 @@ public class DriverLibraryLocal extends DriverLibraryAbstract
@Nullable
@Nullable
@Override
@Override
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
RProgressMonitor
monitor
)
throws
IOException
{
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
PDriverContext
context
)
throws
IOException
{
return
null
;
return
null
;
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenArtifact.java
浏览文件 @
f1243d58
...
@@ -22,8 +22,9 @@ import org.jkiss.code.NotNull;
...
@@ -22,8 +22,9 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.
DBR
ProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.
Void
ProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.*
;
import
org.jkiss.dbeaver.registry.maven.*
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
...
@@ -74,8 +75,8 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -74,8 +75,8 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
}
}
@Override
@Override
public
void
resolve
(
DB
RProgressMonitor
monitor
)
throws
IOException
{
public
void
resolve
(
DB
PDriverContext
context
)
throws
IOException
{
if
(
getArtifactVersion
(
monitor
)
==
null
)
{
if
(
getArtifactVersion
(
context
)
==
null
)
{
throw
new
IOException
(
"Can't resolve artifact "
+
this
+
" version"
);
throw
new
IOException
(
"Can't resolve artifact "
+
this
+
" version"
);
}
}
}
}
...
@@ -83,23 +84,25 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -83,23 +84,25 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Nullable
@Nullable
protected
MavenArtifactVersion
getCachedArtifactVersion
()
{
protected
MavenArtifactVersion
getCachedArtifactVersion
()
{
if
(
localVersion
==
null
)
{
if
(
localVersion
==
null
)
{
localVersion
=
MavenRegistry
.
getInstance
().
findCachedArtifact
(
reference
);
try
(
DBPDriverContext
context
=
new
DBPDriverContext
(
VoidProgressMonitor
.
INSTANCE
))
{
localVersion
=
MavenRegistry
.
getInstance
().
findCachedArtifact
(
context
,
reference
);
}
}
}
return
localVersion
;
return
localVersion
;
}
}
@Nullable
@Nullable
protected
MavenArtifactVersion
getArtifactVersion
(
DB
RProgressMonitor
monitor
)
{
protected
MavenArtifactVersion
getArtifactVersion
(
DB
PDriverContext
context
)
{
if
(
localVersion
==
null
)
{
if
(
localVersion
==
null
)
{
localVersion
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
reference
);
localVersion
=
MavenRegistry
.
getInstance
().
findArtifact
(
context
,
reference
);
}
}
return
localVersion
;
return
localVersion
;
}
}
@Nullable
@Nullable
@Override
@Override
public
String
getExternalURL
(
DB
RProgressMonitor
monitor
)
{
public
String
getExternalURL
(
DB
PDriverContext
context
)
{
MavenArtifactVersion
localVersion
=
getArtifactVersion
(
monitor
);
MavenArtifactVersion
localVersion
=
getArtifactVersion
(
context
);
if
(
localVersion
!=
null
)
{
if
(
localVersion
!=
null
)
{
return
localVersion
.
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
return
localVersion
.
getExternalURL
(
MavenArtifact
.
FILE_JAR
);
}
}
...
@@ -132,18 +135,18 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -132,18 +135,18 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
@Nullable
@Nullable
@Override
@Override
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
RProgressMonitor
monitor
)
throws
IOException
{
public
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
PDriverContext
context
)
throws
IOException
{
List
<
DriverLibraryMavenDependency
>
dependencies
=
new
ArrayList
<>();
List
<
DriverLibraryMavenDependency
>
dependencies
=
new
ArrayList
<>();
MavenArtifactVersion
localVersion
=
resolveLocalVersion
(
monitor
,
false
);
MavenArtifactVersion
localVersion
=
resolveLocalVersion
(
context
,
false
);
if
(
localVersion
!=
null
)
{
if
(
localVersion
!=
null
)
{
List
<
MavenArtifactDependency
>
artifactDeps
=
localVersion
.
getDependencies
(
monitor
);
List
<
MavenArtifactDependency
>
artifactDeps
=
localVersion
.
getDependencies
(
context
);
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
if
(!
CommonUtils
.
isEmpty
(
artifactDeps
))
{
for
(
MavenArtifactDependency
dependency
:
artifactDeps
)
{
for
(
MavenArtifactDependency
dependency
:
artifactDeps
)
{
if
(
isDependencyExcluded
(
monitor
,
dependency
))
{
if
(
isDependencyExcluded
(
context
,
dependency
))
{
continue
;
continue
;
}
}
MavenArtifactVersion
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
dependency
);
MavenArtifactVersion
depArtifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
context
,
dependency
);
if
(
depArtifact
!=
null
)
{
if
(
depArtifact
!=
null
)
{
dependencies
.
add
(
dependencies
.
add
(
new
DriverLibraryMavenDependency
(
new
DriverLibraryMavenDependency
(
...
@@ -160,7 +163,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -160,7 +163,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
dependencies
;
return
dependencies
;
}
}
protected
boolean
isDependencyExcluded
(
DB
RProgressMonitor
monitor
,
MavenArtifactDependency
dependency
)
{
protected
boolean
isDependencyExcluded
(
DB
PDriverContext
context
,
MavenArtifactDependency
dependency
)
{
return
false
;
return
false
;
}
}
...
@@ -190,10 +193,10 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -190,10 +193,10 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return
UIIcon
.
APACHE
;
return
UIIcon
.
APACHE
;
}
}
public
void
downloadLibraryFile
(
@NotNull
DB
RProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
public
void
downloadLibraryFile
(
@NotNull
DB
PDriverContext
context
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
{
//monitor.beginTask(taskName + " - update localVersion information", 1);
//monitor.beginTask(taskName + " - update localVersion information", 1);
try
{
try
{
MavenArtifactVersion
localVersion
=
resolveLocalVersion
(
monitor
,
forceUpdate
);
MavenArtifactVersion
localVersion
=
resolveLocalVersion
(
context
,
forceUpdate
);
if
(
localVersion
.
getArtifact
().
getRepository
().
isLocal
())
{
if
(
localVersion
.
getArtifact
().
getRepository
().
isLocal
())
{
// No need to download local artifacts
// No need to download local artifacts
return
;
return
;
...
@@ -201,14 +204,14 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
...
@@ -201,14 +204,14 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
}
finally
{
}
finally
{
//monitor.done();
//monitor.done();
}
}
super
.
downloadLibraryFile
(
monitor
,
forceUpdate
,
taskName
);
super
.
downloadLibraryFile
(
context
,
forceUpdate
,
taskName
);
}
}
protected
MavenArtifactVersion
resolveLocalVersion
(
DB
RProgressMonitor
monitor
,
boolean
forceUpdate
)
throws
IOException
{
protected
MavenArtifactVersion
resolveLocalVersion
(
DB
PDriverContext
context
,
boolean
forceUpdate
)
throws
IOException
{
if
(
forceUpdate
)
{
if
(
forceUpdate
)
{
MavenRegistry
.
getInstance
().
resetArtifactInfo
(
reference
);
MavenRegistry
.
getInstance
().
resetArtifactInfo
(
reference
);
}
}
MavenArtifactVersion
version
=
getArtifactVersion
(
monitor
);
MavenArtifactVersion
version
=
getArtifactVersion
(
context
);
if
(
version
==
null
)
{
if
(
version
==
null
)
{
throw
new
IOException
(
"Maven artifact '"
+
path
+
"' not found"
);
throw
new
IOException
(
"Maven artifact '"
+
path
+
"' not found"
);
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryMavenDependency.java
浏览文件 @
f1243d58
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
*/
*/
package
org.jkiss.dbeaver.registry.driver
;
package
org.jkiss.dbeaver.registry.driver
;
import
org.jkiss.dbeaver.model.
runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.
connection.DBPDriverContext
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactDependency
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactDependency
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactReference
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactReference
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactVersion
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifactVersion
;
...
@@ -44,7 +44,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
...
@@ -44,7 +44,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
return
true
;
return
true
;
}
}
protected
boolean
isDependencyExcluded
(
DB
RProgressMonitor
monitor
,
MavenArtifactDependency
dependency
)
{
protected
boolean
isDependencyExcluded
(
DB
PDriverContext
context
,
MavenArtifactDependency
dependency
)
{
List
<
MavenArtifactReference
>
exclusions
=
source
.
getExclusions
();
List
<
MavenArtifactReference
>
exclusions
=
source
.
getExclusions
();
if
(
exclusions
!=
null
)
{
if
(
exclusions
!=
null
)
{
for
(
MavenArtifactReference
exReference
:
exclusions
)
{
for
(
MavenArtifactReference
exReference
:
exclusions
)
{
...
@@ -54,7 +54,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
...
@@ -54,7 +54,7 @@ public class DriverLibraryMavenDependency extends DriverLibraryMavenArtifact
}
}
}
}
return
parent
.
isDependencyExcluded
(
monitor
,
dependency
);
return
parent
.
isDependencyExcluded
(
context
,
dependency
);
}
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/driver/DriverLibraryRepository.java
浏览文件 @
f1243d58
...
@@ -19,7 +19,7 @@ package org.jkiss.dbeaver.registry.driver;
...
@@ -19,7 +19,7 @@ package org.jkiss.dbeaver.registry.driver;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.
runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.
connection.DBPDriverContext
;
/**
/**
* DriverLibraryDescriptor
* DriverLibraryDescriptor
...
@@ -49,7 +49,7 @@ public class DriverLibraryRepository extends DriverLibraryLocal
...
@@ -49,7 +49,7 @@ public class DriverLibraryRepository extends DriverLibraryLocal
@Nullable
@Nullable
@Override
@Override
public
String
getExternalURL
(
DB
RProgressMonitor
monitor
)
{
public
String
getExternalURL
(
DB
PDriverContext
context
)
{
String
localPath
=
getLocalFilePath
();
String
localPath
=
getLocalFilePath
();
String
primarySource
=
DriverDescriptor
.
getDriversPrimarySource
();
String
primarySource
=
DriverDescriptor
.
getDriversPrimarySource
();
if
(!
primarySource
.
endsWith
(
"/"
)
&&
!
localPath
.
startsWith
(
"/"
))
{
if
(!
primarySource
.
endsWith
(
"/"
)
&&
!
localPath
.
startsWith
(
"/"
))
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
f1243d58
...
@@ -20,7 +20,7 @@ package org.jkiss.dbeaver.registry.maven;
...
@@ -20,7 +20,7 @@ package org.jkiss.dbeaver.registry.maven;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.
runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.
connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.maven.versioning.DefaultArtifactVersion
;
import
org.jkiss.dbeaver.registry.maven.versioning.DefaultArtifactVersion
;
import
org.jkiss.dbeaver.registry.maven.versioning.VersionRange
;
import
org.jkiss.dbeaver.registry.maven.versioning.VersionRange
;
...
@@ -71,14 +71,14 @@ public class MavenArtifact
...
@@ -71,14 +71,14 @@ public class MavenArtifact
this
.
artifactId
=
artifactId
;
this
.
artifactId
=
artifactId
;
}
}
public
void
loadMetadata
(
DB
RProgressMonitor
monitor
)
throws
IOException
{
public
void
loadMetadata
(
DB
PDriverContext
context
)
throws
IOException
{
latestVersion
=
null
;
latestVersion
=
null
;
releaseVersion
=
null
;
releaseVersion
=
null
;
versions
.
clear
();
versions
.
clear
();
lastUpdate
=
null
;
lastUpdate
=
null
;
String
metadataPath
=
getArtifactURL
()
+
MAVEN_METADATA_XML
;
String
metadataPath
=
getArtifactURL
()
+
MAVEN_METADATA_XML
;
monitor
.
subTask
(
"Load metadata "
+
this
+
""
);
context
.
getMonitor
()
.
subTask
(
"Load metadata "
+
this
+
""
);
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
parseMetadata
(
mdStream
);
parseMetadata
(
mdStream
);
...
@@ -92,7 +92,7 @@ public class MavenArtifact
...
@@ -92,7 +92,7 @@ public class MavenArtifact
log
.
warn
(
"Error parsing artifact directory"
,
e
);
log
.
warn
(
"Error parsing artifact directory"
,
e
);
}
}
}
finally
{
}
finally
{
monitor
.
worked
(
1
);
context
.
getMonitor
()
.
worked
(
1
);
}
}
metadataLoaded
=
true
;
metadataLoaded
=
true
;
}
}
...
@@ -220,10 +220,10 @@ public class MavenArtifact
...
@@ -220,10 +220,10 @@ public class MavenArtifact
localVersions
.
add
(
version
);
localVersions
.
add
(
version
);
}
}
private
MavenArtifactVersion
makeLocalVersion
(
DB
RProgressMonitor
monitor
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
,
IOException
{
private
MavenArtifactVersion
makeLocalVersion
(
DB
PDriverContext
context
,
String
versionStr
,
boolean
setActive
)
throws
IllegalArgumentException
,
IOException
{
MavenArtifactVersion
version
=
getVersion
(
versionStr
);
MavenArtifactVersion
version
=
getVersion
(
versionStr
);
if
(
version
==
null
)
{
if
(
version
==
null
)
{
version
=
new
MavenArtifactVersion
(
monitor
,
this
,
versionStr
,
true
);
version
=
new
MavenArtifactVersion
(
context
,
this
,
versionStr
,
true
);
localVersions
.
add
(
version
);
localVersions
.
add
(
version
);
}
}
if
(
setActive
)
{
if
(
setActive
)
{
...
@@ -233,19 +233,19 @@ public class MavenArtifact
...
@@ -233,19 +233,19 @@ public class MavenArtifact
return
version
;
return
version
;
}
}
public
MavenArtifactVersion
resolveActiveVersion
()
throws
IOException
{
public
MavenArtifactVersion
resolveActiveVersion
(
DBPDriverContext
context
)
throws
IOException
{
if
(
CommonUtils
.
isEmpty
(
activeVersion
))
{
if
(
CommonUtils
.
isEmpty
(
activeVersion
))
{
return
null
;
return
null
;
}
}
MavenArtifactVersion
version
=
getVersion
(
activeVersion
);
MavenArtifactVersion
version
=
getVersion
(
activeVersion
);
if
(
version
==
null
)
{
if
(
version
==
null
)
{
version
=
new
MavenArtifactVersion
(
VoidProgressMonitor
.
INSTANCE
,
this
,
activeVersion
,
false
);
version
=
new
MavenArtifactVersion
(
context
,
this
,
activeVersion
,
false
);
localVersions
.
add
(
version
);
localVersions
.
add
(
version
);
}
}
return
version
;
return
version
;
}
}
public
MavenArtifactVersion
resolveVersion
(
DB
RProgressMonitor
monitor
,
String
versionRef
)
throws
IOException
{
public
MavenArtifactVersion
resolveVersion
(
DB
PDriverContext
context
,
String
versionRef
)
throws
IOException
{
if
(
CommonUtils
.
isEmpty
(
versionRef
))
{
if
(
CommonUtils
.
isEmpty
(
versionRef
))
{
throw
new
IOException
(
"Empty artifact "
+
this
+
" version"
);
throw
new
IOException
(
"Empty artifact "
+
this
+
" version"
);
}
}
...
@@ -269,7 +269,7 @@ public class MavenArtifact
...
@@ -269,7 +269,7 @@ public class MavenArtifact
}
}
}
}
if
(
lookupVersion
&&
!
metadataLoaded
)
{
if
(
lookupVersion
&&
!
metadataLoaded
)
{
loadMetadata
(
monitor
);
loadMetadata
(
context
);
}
}
String
versionInfo
;
String
versionInfo
;
...
@@ -323,7 +323,7 @@ public class MavenArtifact
...
@@ -323,7 +323,7 @@ public class MavenArtifact
MavenArtifactVersion
localVersion
=
getVersion
(
versionInfo
);
MavenArtifactVersion
localVersion
=
getVersion
(
versionInfo
);
if
(
localVersion
==
null
)
{
if
(
localVersion
==
null
)
{
localVersion
=
makeLocalVersion
(
monitor
,
versionInfo
,
lookupVersion
);
localVersion
=
makeLocalVersion
(
context
,
versionInfo
,
lookupVersion
);
}
}
return
localVersion
;
return
localVersion
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifactVersion.java
浏览文件 @
f1243d58
...
@@ -18,10 +18,8 @@
...
@@ -18,10 +18,8 @@
package
org.jkiss.dbeaver.registry.maven
;
package
org.jkiss.dbeaver.registry.maven
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
...
@@ -86,16 +84,10 @@ public class MavenArtifactVersion {
...
@@ -86,16 +84,10 @@ public class MavenArtifactVersion {
}
}
};
};
/**
MavenArtifactVersion
(
@NotNull
DBPDriverContext
context
,
@NotNull
MavenArtifact
artifact
,
@NotNull
String
version
,
boolean
readRemote
)
throws
IOException
{
* Makes new version
* @param monitor if null then do not try to get remote POM
* @param readRemote
* @throws IOException
*/
MavenArtifactVersion
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
MavenArtifact
artifact
,
@NotNull
String
version
,
boolean
readRemote
)
throws
IOException
{
this
.
artifact
=
artifact
;
this
.
artifact
=
artifact
;
this
.
version
=
version
;
this
.
version
=
version
;
loadPOM
(
monitor
,
readRemote
);
loadPOM
(
context
,
readRemote
);
}
}
public
MavenArtifact
getArtifact
()
{
public
MavenArtifact
getArtifact
()
{
...
@@ -126,7 +118,7 @@ public class MavenArtifactVersion {
...
@@ -126,7 +118,7 @@ public class MavenArtifactVersion {
return
licenses
;
return
licenses
;
}
}
public
List
<
MavenArtifactDependency
>
getDependencies
(
DB
RProgressMonitor
monitor
)
{
public
List
<
MavenArtifactDependency
>
getDependencies
(
DB
PDriverContext
context
)
{
List
<
MavenArtifactDependency
>
dependencies
=
new
ArrayList
<>();
List
<
MavenArtifactDependency
>
dependencies
=
new
ArrayList
<>();
for
(
MavenProfile
profile
:
profiles
)
{
for
(
MavenProfile
profile
:
profiles
)
{
if
(
profile
.
isActive
()
&&
!
CommonUtils
.
isEmpty
(
profile
.
dependencies
))
{
if
(
profile
.
isActive
()
&&
!
CommonUtils
.
isEmpty
(
profile
.
dependencies
))
{
...
@@ -134,7 +126,7 @@ public class MavenArtifactVersion {
...
@@ -134,7 +126,7 @@ public class MavenArtifactVersion {
}
}
}
}
if
(
parent
!=
null
)
{
if
(
parent
!=
null
)
{
List
<
MavenArtifactDependency
>
parentDependencies
=
parent
.
getDependencies
(
monitor
);
List
<
MavenArtifactDependency
>
parentDependencies
=
parent
.
getDependencies
(
context
);
if
(!
CommonUtils
.
isEmpty
(
parentDependencies
))
{
if
(!
CommonUtils
.
isEmpty
(
parentDependencies
))
{
dependencies
.
addAll
(
parentDependencies
);
dependencies
.
addAll
(
parentDependencies
);
}
}
...
@@ -185,7 +177,7 @@ public class MavenArtifactVersion {
...
@@ -185,7 +177,7 @@ public class MavenArtifactVersion {
return
artifact
.
getFileURL
(
version
,
MavenArtifact
.
FILE_POM
);
return
artifact
.
getFileURL
(
version
,
MavenArtifact
.
FILE_POM
);
}
}
private
void
loadPOM
(
DB
RProgressMonitor
monitor
,
boolean
readRemote
)
throws
IOException
{
private
void
loadPOM
(
DB
PDriverContext
context
,
boolean
readRemote
)
throws
IOException
{
File
localPOM
=
getLocalPOM
();
File
localPOM
=
getLocalPOM
();
if
(!
localPOM
.
exists
())
{
if
(!
localPOM
.
exists
())
{
if
(
readRemote
)
{
if
(
readRemote
)
{
...
@@ -196,7 +188,7 @@ public class MavenArtifactVersion {
...
@@ -196,7 +188,7 @@ public class MavenArtifactVersion {
}
}
}
}
monitor
.
subTask
(
"Load POM "
+
this
);
context
.
getMonitor
()
.
subTask
(
"Load POM "
+
this
);
Document
pomDocument
;
Document
pomDocument
;
try
(
InputStream
mdStream
=
new
FileInputStream
(
localPOM
))
{
try
(
InputStream
mdStream
=
new
FileInputStream
(
localPOM
))
{
...
@@ -227,7 +219,7 @@ public class MavenArtifactVersion {
...
@@ -227,7 +219,7 @@ public class MavenArtifactVersion {
if
(
this
.
version
==
null
)
{
if
(
this
.
version
==
null
)
{
this
.
version
=
parentReference
.
getVersion
();
this
.
version
=
parentReference
.
getVersion
();
}
}
parent
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
parentReference
);
parent
=
MavenRegistry
.
getInstance
().
findArtifact
(
context
,
parentReference
);
if
(
parent
==
null
)
{
if
(
parent
==
null
)
{
log
.
error
(
"Artifact ["
+
this
+
"] parent ["
+
parentReference
+
"] not found"
);
log
.
error
(
"Artifact ["
+
this
+
"] parent ["
+
parentReference
+
"] not found"
);
}
}
...
@@ -252,7 +244,7 @@ public class MavenArtifactVersion {
...
@@ -252,7 +244,7 @@ public class MavenArtifactVersion {
MavenProfile
defaultProfile
=
new
MavenProfile
(
DEFAULT_PROFILE_ID
);
MavenProfile
defaultProfile
=
new
MavenProfile
(
DEFAULT_PROFILE_ID
);
defaultProfile
.
active
=
true
;
defaultProfile
.
active
=
true
;
profiles
.
add
(
defaultProfile
);
profiles
.
add
(
defaultProfile
);
parseProfile
(
monitor
,
defaultProfile
,
root
);
parseProfile
(
context
,
defaultProfile
,
root
);
{
{
// Profiles
// Profiles
...
@@ -261,15 +253,15 @@ public class MavenArtifactVersion {
...
@@ -261,15 +253,15 @@ public class MavenArtifactVersion {
for
(
Element
profElement
:
XMLUtils
.
getChildElementList
(
licensesElement
,
"profile"
))
{
for
(
Element
profElement
:
XMLUtils
.
getChildElementList
(
licensesElement
,
"profile"
))
{
MavenProfile
profile
=
new
MavenProfile
(
XMLUtils
.
getChildElementBody
(
profElement
,
"id"
));
MavenProfile
profile
=
new
MavenProfile
(
XMLUtils
.
getChildElementBody
(
profElement
,
"id"
));
profiles
.
add
(
profile
);
profiles
.
add
(
profile
);
parseProfile
(
monitor
,
profile
,
profElement
);
parseProfile
(
context
,
profile
,
profElement
);
}
}
}
}
}
}
monitor
.
worked
(
1
);
context
.
getMonitor
()
.
worked
(
1
);
}
}
private
void
parseProfile
(
DB
RProgressMonitor
monitor
,
MavenProfile
profile
,
Element
element
)
{
private
void
parseProfile
(
DB
PDriverContext
context
,
MavenProfile
profile
,
Element
element
)
{
{
{
// Activation
// Activation
Element
activationElement
=
XMLUtils
.
getChildElement
(
element
,
"activation"
);
Element
activationElement
=
XMLUtils
.
getChildElement
(
element
,
"activation"
);
...
@@ -314,9 +306,9 @@ public class MavenArtifactVersion {
...
@@ -314,9 +306,9 @@ public class MavenArtifactVersion {
// Dependencies
// Dependencies
Element
dmElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencyManagement"
);
Element
dmElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencyManagement"
);
if
(
dmElement
!=
null
)
{
if
(
dmElement
!=
null
)
{
profile
.
dependencyManagement
=
parseDependencies
(
monitor
,
dmElement
,
true
);
profile
.
dependencyManagement
=
parseDependencies
(
context
,
dmElement
,
true
);
}
}
profile
.
dependencies
=
parseDependencies
(
monitor
,
element
,
false
);
profile
.
dependencies
=
parseDependencies
(
context
,
element
,
false
);
}
}
}
}
...
@@ -337,7 +329,7 @@ public class MavenArtifactVersion {
...
@@ -337,7 +329,7 @@ public class MavenArtifactVersion {
}
}
}
}
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DB
RProgressMonitor
monitor
,
Element
element
,
boolean
depManagement
)
{
private
List
<
MavenArtifactDependency
>
parseDependencies
(
DB
PDriverContext
context
,
Element
element
,
boolean
depManagement
)
{
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
List
<
MavenArtifactDependency
>
result
=
new
ArrayList
<>();
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
Element
dependenciesElement
=
XMLUtils
.
getChildElement
(
element
,
"dependencies"
);
if
(
dependenciesElement
!=
null
)
{
if
(
dependenciesElement
!=
null
)
{
...
@@ -367,7 +359,7 @@ public class MavenArtifactVersion {
...
@@ -367,7 +359,7 @@ public class MavenArtifactVersion {
groupId
,
groupId
,
artifactId
,
artifactId
,
version
);
version
);
MavenArtifactVersion
importedVersion
=
MavenRegistry
.
getInstance
().
findArtifact
(
monitor
,
importReference
);
MavenArtifactVersion
importedVersion
=
MavenRegistry
.
getInstance
().
findArtifact
(
context
,
importReference
);
if
(
importedVersion
==
null
)
{
if
(
importedVersion
==
null
)
{
log
.
error
(
"Imported artifact ["
+
importReference
+
"] not found. Skip."
);
log
.
error
(
"Imported artifact ["
+
importReference
+
"] not found. Skip."
);
}
}
...
@@ -379,7 +371,7 @@ public class MavenArtifactVersion {
...
@@ -379,7 +371,7 @@ public class MavenArtifactVersion {
// TODO: maybe we should include optional or PROVIDED
// TODO: maybe we should include optional or PROVIDED
if
(
version
==
null
)
{
if
(
version
==
null
)
{
version
=
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
version
=
findDependencyVersion
(
context
,
groupId
,
artifactId
);
}
}
if
(
version
==
null
)
{
if
(
version
==
null
)
{
log
.
error
(
"Can't resolve artifact ["
+
groupId
+
":"
+
artifactId
+
"] version. Skip."
);
log
.
error
(
"Can't resolve artifact ["
+
groupId
+
":"
+
artifactId
+
"] version. Skip."
);
...
@@ -421,7 +413,7 @@ public class MavenArtifactVersion {
...
@@ -421,7 +413,7 @@ public class MavenArtifactVersion {
scope == MavenArtifactDependency.Scope.PROVIDED*/
;
scope == MavenArtifactDependency.Scope.PROVIDED*/
;
}
}
private
String
findDependencyVersion
(
DB
RProgressMonitor
monitor
,
String
groupId
,
String
artifactId
)
{
private
String
findDependencyVersion
(
DB
PDriverContext
context
,
String
groupId
,
String
artifactId
)
{
for
(
MavenProfile
profile
:
profiles
)
{
for
(
MavenProfile
profile
:
profiles
)
{
if
(
profile
.
isActive
()
&&
profile
.
dependencyManagement
!=
null
)
{
if
(
profile
.
isActive
()
&&
profile
.
dependencyManagement
!=
null
)
{
for
(
MavenArtifactDependency
dmArtifact
:
profile
.
dependencyManagement
)
{
for
(
MavenArtifactDependency
dmArtifact
:
profile
.
dependencyManagement
)
{
...
@@ -435,13 +427,13 @@ public class MavenArtifactVersion {
...
@@ -435,13 +427,13 @@ public class MavenArtifactVersion {
// Check in imported BOMs
// Check in imported BOMs
if
(
imports
!=
null
)
{
if
(
imports
!=
null
)
{
for
(
MavenArtifactVersion
i
:
imports
)
{
for
(
MavenArtifactVersion
i
:
imports
)
{
String
dependencyVersion
=
i
.
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
String
dependencyVersion
=
i
.
findDependencyVersion
(
context
,
groupId
,
artifactId
);
if
(
dependencyVersion
!=
null
)
{
if
(
dependencyVersion
!=
null
)
{
return
dependencyVersion
;
return
dependencyVersion
;
}
}
}
}
}
}
return
parent
==
null
?
null
:
parent
.
findDependencyVersion
(
monitor
,
groupId
,
artifactId
);
return
parent
==
null
?
null
:
parent
.
findDependencyVersion
(
context
,
groupId
,
artifactId
);
}
}
private
String
evaluateString
(
String
value
)
{
private
String
evaluateString
(
String
value
)
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenContext.java
→
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenContext
Info
.java
浏览文件 @
f1243d58
...
@@ -17,37 +17,19 @@
...
@@ -17,37 +17,19 @@
*/
*/
package
org.jkiss.dbeaver.registry.maven
;
package
org.jkiss.dbeaver.registry.maven
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
*
Maven
resolve context
*
Driver
resolve context
*/
*/
public
class
MavenContext
implements
AutoCloseable
{
public
class
MavenContext
Info
{
private
final
DBRProgressMonitor
monitor
;
private
final
Date
initTime
=
new
Date
();
private
final
Map
<
String
,
String
>
properties
=
new
HashMap
<>();
private
final
Map
<
MavenArtifactVersion
,
List
<
MavenRepository
>>
artifactRepositories
=
new
LinkedHashMap
<>();
private
final
Map
<
MavenArtifactVersion
,
List
<
MavenRepository
>>
artifactRepositories
=
new
LinkedHashMap
<>();
private
final
List
<
MavenRepository
>
activeRepositories
=
new
ArrayList
<>();
private
final
List
<
MavenRepository
>
activeRepositories
=
new
ArrayList
<>();
public
MavenContext
(
DBRProgressMonitor
monitor
)
{
this
.
monitor
=
monitor
;
}
public
DBRProgressMonitor
getMonitor
()
{
return
monitor
;
}
public
Date
getInitTime
()
{
return
initTime
;
}
public
Map
<
String
,
String
>
getProperties
()
{
return
properties
;
}
public
List
<
MavenRepository
>
getActiveRepositories
()
{
public
List
<
MavenRepository
>
getActiveRepositories
()
{
return
activeRepositories
;
return
activeRepositories
;
}
}
...
@@ -60,8 +42,4 @@ public class MavenContext implements AutoCloseable {
...
@@ -60,8 +42,4 @@ public class MavenContext implements AutoCloseable {
artifactRepositories
.
remove
(
artifactVersion
);
artifactRepositories
.
remove
(
artifactVersion
);
}
}
@Override
public
void
close
()
{
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
浏览文件 @
f1243d58
...
@@ -25,6 +25,7 @@ import org.jkiss.code.NotNull;
...
@@ -25,6 +25,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.DBeaverPreferences
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.runtime.AbstractJob
;
import
org.jkiss.dbeaver.runtime.AbstractJob
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
...
@@ -133,12 +134,12 @@ public class MavenRegistry
...
@@ -133,12 +134,12 @@ public class MavenRegistry
}
}
@Nullable
@Nullable
public
MavenArtifactVersion
findArtifact
(
@NotNull
DB
RProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
public
MavenArtifactVersion
findArtifact
(
@NotNull
DB
PDriverContext
context
,
@NotNull
MavenArtifactReference
ref
)
{
String
fullId
=
ref
.
getId
();
String
fullId
=
ref
.
getId
();
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
return
null
;
return
null
;
}
}
MavenArtifactVersion
artifact
=
findInRepositories
(
monitor
,
ref
);
MavenArtifactVersion
artifact
=
findInRepositories
(
context
,
ref
);
if
(
artifact
!=
null
)
{
if
(
artifact
!=
null
)
{
return
artifact
;
return
artifact
;
}
}
...
@@ -149,19 +150,19 @@ public class MavenRegistry
...
@@ -149,19 +150,19 @@ public class MavenRegistry
}
}
@Nullable
@Nullable
public
MavenArtifactVersion
findCachedArtifact
(
@NotNull
MavenArtifactReference
ref
)
{
public
MavenArtifactVersion
findCachedArtifact
(
DBPDriverContext
context
,
@NotNull
MavenArtifactReference
ref
)
{
String
fullId
=
ref
.
getId
();
String
fullId
=
ref
.
getId
();
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
if
(
notFoundArtifacts
.
contains
(
fullId
))
{
return
null
;
return
null
;
}
}
// Try all available repositories (without resolve)
// Try all available repositories (without resolve)
for
(
MavenRepository
repository
:
repositories
)
{
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifactVersion
artifact
=
repository
.
findCachedArtifact
(
ref
);
MavenArtifactVersion
artifact
=
repository
.
findCachedArtifact
(
context
,
ref
);
if
(
artifact
!=
null
)
{
if
(
artifact
!=
null
)
{
return
artifact
;
return
artifact
;
}
}
}
}
MavenArtifactVersion
artifact
=
localRepository
.
findCachedArtifact
(
ref
);
MavenArtifactVersion
artifact
=
localRepository
.
findCachedArtifact
(
context
,
ref
);
if
(
artifact
!=
null
)
{
if
(
artifact
!=
null
)
{
return
artifact
;
return
artifact
;
}
}
...
@@ -178,15 +179,15 @@ public class MavenRegistry
...
@@ -178,15 +179,15 @@ public class MavenRegistry
}
}
@Nullable
@Nullable
private
MavenArtifactVersion
findInRepositories
(
@NotNull
DB
RProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
private
MavenArtifactVersion
findInRepositories
(
@NotNull
DB
PDriverContext
context
,
@NotNull
MavenArtifactReference
ref
)
{
// Try all available repositories (without resolve)
// Try all available repositories (without resolve)
for
(
MavenRepository
repository
:
repositories
)
{
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifactVersion
artifact
=
repository
.
findArtifact
(
monitor
,
ref
);
MavenArtifactVersion
artifact
=
repository
.
findArtifact
(
context
,
ref
);
if
(
artifact
!=
null
)
{
if
(
artifact
!=
null
)
{
return
artifact
;
return
artifact
;
}
}
}
}
MavenArtifactVersion
artifact
=
localRepository
.
findArtifact
(
monitor
,
ref
);
MavenArtifactVersion
artifact
=
localRepository
.
findArtifact
(
context
,
ref
);
if
(
artifact
!=
null
)
{
if
(
artifact
!=
null
)
{
return
artifact
;
return
artifact
;
}
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
浏览文件 @
f1243d58
...
@@ -22,7 +22,7 @@ import org.jkiss.code.NotNull;
...
@@ -22,7 +22,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.model.
runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.
connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
...
@@ -112,7 +112,7 @@ public class MavenRepository
...
@@ -112,7 +112,7 @@ public class MavenRepository
}
}
@Nullable
@Nullable
public
synchronized
MavenArtifactVersion
findArtifact
(
DB
RProgressMonitor
monitor
,
@NotNull
MavenArtifactReference
ref
)
{
public
synchronized
MavenArtifactVersion
findArtifact
(
DB
PDriverContext
context
,
@NotNull
MavenArtifactReference
ref
)
{
boolean
newArtifact
=
false
;
boolean
newArtifact
=
false
;
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
if
(
artifact
==
null
)
{
if
(
artifact
==
null
)
{
...
@@ -120,7 +120,7 @@ public class MavenRepository
...
@@ -120,7 +120,7 @@ public class MavenRepository
newArtifact
=
true
;
newArtifact
=
true
;
}
}
try
{
try
{
MavenArtifactVersion
version
=
artifact
.
resolveVersion
(
monitor
,
ref
.
getVersion
());
MavenArtifactVersion
version
=
artifact
.
resolveVersion
(
context
,
ref
.
getVersion
());
if
(
newArtifact
)
{
if
(
newArtifact
)
{
cachedArtifacts
.
put
(
ref
.
getId
(),
artifact
);
cachedArtifacts
.
put
(
ref
.
getId
(),
artifact
);
flushCache
();
flushCache
();
...
@@ -132,7 +132,7 @@ public class MavenRepository
...
@@ -132,7 +132,7 @@ public class MavenRepository
}
}
}
}
public
MavenArtifactVersion
findCachedArtifact
(
MavenArtifactReference
ref
)
{
public
MavenArtifactVersion
findCachedArtifact
(
DBPDriverContext
context
,
MavenArtifactReference
ref
)
{
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
MavenArtifact
artifact
=
cachedArtifacts
.
get
(
ref
.
getId
());
if
(
artifact
==
null
)
{
if
(
artifact
==
null
)
{
return
null
;
return
null
;
...
@@ -141,7 +141,7 @@ public class MavenRepository
...
@@ -141,7 +141,7 @@ public class MavenRepository
if
(
version
==
null
&&
!
CommonUtils
.
isEmpty
(
artifact
.
getActiveVersionName
()))
{
if
(
version
==
null
&&
!
CommonUtils
.
isEmpty
(
artifact
.
getActiveVersionName
()))
{
// Resolve active version
// Resolve active version
try
{
try
{
version
=
artifact
.
resolveActiveVersion
();
version
=
artifact
.
resolveActiveVersion
(
context
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
warn
(
"Can't resolve cached active version "
+
ref
);
log
.
warn
(
"Can't resolve cached active version "
+
ref
);
}
}
...
@@ -170,6 +170,7 @@ public class MavenRepository
...
@@ -170,6 +170,7 @@ public class MavenRepository
if
(!
cacheFile
.
exists
())
{
if
(!
cacheFile
.
exists
())
{
return
;
return
;
}
}
final
DBPDriverContext
context
=
new
DBPDriverContext
(
VoidProgressMonitor
.
INSTANCE
);
try
{
try
{
InputStream
mdStream
=
new
FileInputStream
(
cacheFile
);
InputStream
mdStream
=
new
FileInputStream
(
cacheFile
);
try
{
try
{
...
@@ -191,7 +192,7 @@ public class MavenRepository
...
@@ -191,7 +192,7 @@ public class MavenRepository
String
versionNumber
=
atts
.
getValue
(
ATTR_VERSION
);
String
versionNumber
=
atts
.
getValue
(
ATTR_VERSION
);
try
{
try
{
MavenArtifactVersion
version
=
new
MavenArtifactVersion
(
MavenArtifactVersion
version
=
new
MavenArtifactVersion
(
VoidProgressMonitor
.
INSTANCE
,
context
,
lastArtifact
,
lastArtifact
,
versionNumber
,
versionNumber
,
false
);
false
);
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/dialogs/driver/DriverDownloadAutoPage.java
浏览文件 @
f1243d58
...
@@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
...
@@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.model.connection.DBPDriverContext
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverDependencies
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.connection.DBPDriverLibrary
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
@@ -170,48 +171,12 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
...
@@ -170,48 +171,12 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
return
;
return
;
}
}
List
<
DBPDriverLibrary
>
files
=
dependencies
.
getLibraryList
();
for
(
int
i
=
0
,
filesSize
=
files
.
size
();
i
<
filesSize
;
)
{
DBPDriverLibrary
lib
=
files
.
get
(
i
);
int
result
=
downloadLibraryFile
(
runnableContext
,
lib
,
"Download "
+
(
i
+
1
)
+
"/"
+
filesSize
);
switch
(
result
)
{
case
IDialogConstants
.
CANCEL_ID
:
case
IDialogConstants
.
ABORT_ID
:
return
;
case
IDialogConstants
.
RETRY_ID
:
continue
;
case
IDialogConstants
.
OK_ID
:
case
IDialogConstants
.
IGNORE_ID
:
i
++;
break
;
}
}
}
private
int
downloadLibraryFile
(
DBRRunnableContext
runnableContext
,
final
DBPDriverLibrary
file
,
final
String
taskName
)
{
try
{
try
{
runnableContext
.
run
(
true
,
true
,
new
DBRRunnableWithProgress
()
{
runnableContext
.
run
(
true
,
true
,
new
LibraryDownloader
());
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
file
.
downloadLibraryFile
(
monitor
,
false
,
taskName
);
}
catch
(
IOException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
});
return
IDialogConstants
.
OK_ID
;
}
catch
(
InterruptedException
e
)
{
// User just canceled download
return
IDialogConstants
.
CANCEL_ID
;
}
catch
(
InvocationTargetException
e
)
{
}
catch
(
InvocationTargetException
e
)
{
if
(
file
.
getType
()
==
DBPDriverLibrary
.
FileType
.
license
)
{
UIUtils
.
showErrorDialog
(
getShell
(),
"Driver download"
,
"Error downloading driver files"
,
e
.
getTargetException
());
return
IDialogConstants
.
OK_ID
;
}
catch
(
InterruptedException
e
)
{
}
// ignore
DownloadRetry
retryConfirm
=
new
DownloadRetry
(
file
,
e
.
getTargetException
());
UIUtils
.
runInUI
(
null
,
retryConfirm
);
return
retryConfirm
.
result
;
}
}
}
}
...
@@ -282,4 +247,38 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
...
@@ -282,4 +247,38 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
}
}
}
}
private
class
LibraryDownloader
implements
DBRRunnableWithProgress
{
@Override
public
void
run
(
DBRProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
DBPDriverContext
context
=
new
DBPDriverContext
(
monitor
);
List
<
DBPDriverLibrary
>
files
=
dependencies
.
getLibraryList
();
for
(
int
i
=
0
,
filesSize
=
files
.
size
();
i
<
filesSize
;
)
{
DBPDriverLibrary
lib
=
files
.
get
(
i
);
int
result
=
IDialogConstants
.
OK_ID
;
try
{
lib
.
downloadLibraryFile
(
context
,
false
,
"Download "
+
(
i
+
1
)
+
"/"
+
filesSize
);
}
catch
(
IOException
e
)
{
if
(
lib
.
getType
()
==
DBPDriverLibrary
.
FileType
.
license
)
{
result
=
IDialogConstants
.
OK_ID
;
}
else
{
DownloadRetry
retryConfirm
=
new
DownloadRetry
(
lib
,
e
);
UIUtils
.
runInUI
(
null
,
retryConfirm
);
result
=
retryConfirm
.
result
;
}
}
switch
(
result
)
{
case
IDialogConstants
.
CANCEL_ID
:
case
IDialogConstants
.
ABORT_ID
:
return
;
case
IDialogConstants
.
RETRY_ID
:
continue
;
case
IDialogConstants
.
OK_ID
:
case
IDialogConstants
.
IGNORE_ID
:
i
++;
break
;
}
}
}
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverContext.java
0 → 100644
浏览文件 @
f1243d58
/*
* 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.model.connection
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.util.*
;
/**
* Driver resolve context
*/
public
class
DBPDriverContext
implements
AutoCloseable
{
static
final
Log
log
=
Log
.
getLog
(
DBPDriverContext
.
class
);
private
final
DBRProgressMonitor
monitor
;
private
final
Date
initTime
=
new
Date
();
private
final
Map
<
String
,
String
>
properties
=
new
HashMap
<>();
private
final
Map
<
Class
,
Object
>
infoMap
=
new
HashMap
<>();
public
DBPDriverContext
(
DBRProgressMonitor
monitor
)
{
this
.
monitor
=
monitor
;
}
public
DBRProgressMonitor
getMonitor
()
{
return
monitor
;
}
public
Date
getInitTime
()
{
return
initTime
;
}
public
Map
<
String
,
String
>
getProperties
()
{
return
properties
;
}
public
<
T
>
T
getInfo
(
Class
<
T
>
type
)
{
Object
o
=
infoMap
.
get
(
type
);
if
(
o
==
null
)
{
try
{
o
=
type
.
newInstance
();
}
catch
(
Exception
e
)
{
log
.
error
(
"Can't create context info "
+
type
.
getName
(),
e
);
}
infoMap
.
put
(
type
,
o
);
}
return
type
.
cast
(
o
);
}
@Override
public
void
close
()
{
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPDriverLibrary.java
浏览文件 @
f1243d58
...
@@ -79,16 +79,16 @@ public interface DBPDriverLibrary
...
@@ -79,16 +79,16 @@ public interface DBPDriverLibrary
boolean
isDisabled
();
boolean
isDisabled
();
void
setDisabled
(
boolean
diabled
);
void
setDisabled
(
boolean
di
s
abled
);
boolean
isDownloadable
();
boolean
isDownloadable
();
boolean
isResolved
();
boolean
isResolved
();
void
resolve
(
DB
RProgressMonitor
monitor
)
throws
IOException
;
void
resolve
(
DB
PDriverContext
context
)
throws
IOException
;
@Nullable
@Nullable
String
getExternalURL
(
DB
RProgressMonitor
monitor
);
String
getExternalURL
(
DB
PDriverContext
context
);
@Nullable
@Nullable
File
getLocalFile
();
File
getLocalFile
();
...
@@ -96,8 +96,8 @@ public interface DBPDriverLibrary
...
@@ -96,8 +96,8 @@ public interface DBPDriverLibrary
boolean
matchesCurrentPlatform
();
boolean
matchesCurrentPlatform
();
@Nullable
@Nullable
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
RProgressMonitor
monitor
)
throws
IOException
;
Collection
<?
extends
DBPDriverLibrary
>
getDependencies
(
@NotNull
DB
PDriverContext
context
)
throws
IOException
;
void
downloadLibraryFile
(
@NotNull
DB
RProgressMonitor
monitor
,
boolean
forceUpdate
,
String
taskName
)
void
downloadLibraryFile
(
@NotNull
DB
PDriverContext
context
,
boolean
forceUpdate
,
String
taskName
)
throws
IOException
,
InterruptedException
;
throws
IOException
,
InterruptedException
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录