Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
2236f9a6
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,发现更多精彩内容 >>
提交
2236f9a6
编写于
8月 31, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Drivers in maven
上级
335308f6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
418 addition
and
0 deletion
+418
-0
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+5
-0
plugins/org.jkiss.dbeaver.core/schema/org.jkiss.dbeaver.mavenRepository.exsd
...beaver.core/schema/org.jkiss.dbeaver.mavenRepository.exsd
+92
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
.../src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
+3
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+144
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
+97
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
...src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
+77
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
2236f9a6
...
...
@@ -22,6 +22,7 @@
<plugin>
<extension-point
id=
"org.jkiss.dbeaver.pluginService"
name=
"Plugin service"
schema=
"schema/org.jkiss.dbeaver.pluginService.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.mavenRepository"
name=
"Maven repositories config"
schema=
"schema/org.jkiss.dbeaver.mavenRepository.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.dataSourceProvider"
name=
"DataSource provider"
schema=
"schema/org.jkiss.dbeaver.dataSourceProvider.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.databaseEditor"
name=
"Custom Entity Editor"
schema=
"schema/org.jkiss.dbeaver.databaseEditor.exsd"
/>
<extension-point
id=
"org.jkiss.dbeaver.dataTypeProvider"
name=
"DataType provider"
schema=
"schema/org.jkiss.dbeaver.dataTypeProvider.exsd"
/>
...
...
@@ -2501,4 +2502,8 @@
<service
class=
"org.jkiss.dbeaver.ui.actions.DataSourcePropertyTester$QMService"
/>
</extension>
<extension
point=
"org.jkiss.dbeaver.mavenRepository"
>
<repository
name=
"Central Repository"
url=
"http://central.maven.org/maven2/"
/>
</extension>
</plugin>
plugins/org.jkiss.dbeaver.core/schema/org.jkiss.dbeaver.mavenRepository.exsd
0 → 100644
浏览文件 @
2236f9a6
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema
targetNamespace=
"org.jkiss.dbeaver.core"
xmlns=
"http://www.w3.org/2001/XMLSchema"
>
<annotation>
<appInfo>
<meta.schema
plugin=
"org.jkiss.dbeaver.core"
id=
"org.jkiss.dbeaver.mavenRepository"
name=
"Maven Repository"
/>
</appInfo>
<documentation>
Plugin Service
</documentation>
</annotation>
<element
name=
"extension"
>
<annotation>
<appInfo>
<meta.element
/>
</appInfo>
</annotation>
<complexType>
<sequence>
<element
ref=
"service"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</sequence>
<attribute
name=
"point"
type=
"string"
use=
"required"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute
name=
"class"
type=
"string"
>
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element
name=
"service"
>
<complexType>
<attribute
name=
"class"
type=
"string"
>
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute
kind=
"java"
basedOn=
":org.jkiss.dbeaver.runtime.IPluginService"
/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section
type=
"since"
/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"examples"
/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"apiinfo"
/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section
type=
"implementation"
/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DriverFileDescriptor.java
浏览文件 @
2236f9a6
...
...
@@ -25,6 +25,8 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import
org.jkiss.dbeaver.model.DBPDriverFile
;
import
org.jkiss.dbeaver.model.DBPDriverFileType
;
import
org.jkiss.dbeaver.model.runtime.OSDescriptor
;
import
org.jkiss.dbeaver.registry.maven.MavenArtifact
;
import
org.jkiss.dbeaver.registry.maven.MavenRegistry
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -140,6 +142,7 @@ public class DriverFileDescriptor implements DBPDriverFile
private
File
getLocalFile
()
{
if
(
path
.
startsWith
(
FILE_SOURCE_MAVEN
))
{
MavenArtifact
artifact
=
MavenRegistry
.
getInstance
().
findArtifact
(
path
);
return
new
File
(
DriverDescriptor
.
getCustomDriversHome
(),
getMavenArtifactFileName
());
}
// Try to use relative path from installation dir
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
0 → 100644
浏览文件 @
2236f9a6
/*
* 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.registry.maven
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.utils.xml.SAXListener
;
import
org.jkiss.utils.xml.SAXReader
;
import
org.jkiss.utils.xml.XMLException
;
import
org.xml.sax.Attributes
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* Maven artifact descriptor
*/
public
class
MavenArtifact
{
static
final
Log
log
=
Log
.
getLog
(
MavenArtifact
.
class
);
private
final
MavenRepository
repository
;
private
final
String
groupId
;
private
final
String
artifactId
;
private
List
<
String
>
versions
=
new
ArrayList
<
String
>();
private
String
latestVersion
;
private
String
releaseVersion
;
private
Date
lastUpdate
;
public
MavenArtifact
(
MavenRepository
repository
,
String
groupId
,
String
artifactId
)
throws
IOException
{
this
.
repository
=
repository
;
this
.
groupId
=
groupId
;
this
.
artifactId
=
artifactId
;
String
metadataPath
=
getArtifactDir
()
+
"maven-metadata.xml"
;
URL
url
=
new
URL
(
metadataPath
);
URLConnection
connection
=
url
.
openConnection
();
connection
.
connect
();
InputStream
mdStream
=
connection
.
getInputStream
();
try
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
public
String
lastTag
;
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
lastTag
=
localName
;
}
@Override
public
void
saxText
(
SAXReader
reader
,
String
data
)
throws
XMLException
{
if
(
"version"
.
equals
(
lastTag
))
{
versions
.
add
(
data
);
}
else
if
(
"latest"
.
equals
(
lastTag
))
{
latestVersion
=
data
;
}
else
if
(
"release"
.
equals
(
lastTag
))
{
releaseVersion
=
data
;
}
else
if
(
"lastUpdate"
.
equals
(
lastTag
))
{
try
{
lastUpdate
=
new
Date
(
Long
.
parseLong
(
data
));
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
e
);
}
}
}
@Override
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
lastTag
=
null
;
}
});
}
catch
(
XMLException
e
)
{
log
.
warn
(
"Error parsing artifact metadata"
,
e
);
}
finally
{
mdStream
.
close
();
}
}
public
MavenRepository
getRepository
()
{
return
repository
;
}
public
String
getGroupId
()
{
return
groupId
;
}
public
String
getArtifactId
()
{
return
artifactId
;
}
public
List
<
String
>
getVersions
()
{
return
versions
;
}
public
String
getLatestVersion
()
{
return
latestVersion
;
}
public
String
getReleaseVersion
()
{
return
releaseVersion
;
}
public
Date
getLastUpdate
()
{
return
lastUpdate
;
}
private
String
getArtifactDir
()
{
String
dir
=
(
groupId
+
"/"
+
artifactId
).
replace
(
'.'
,
'/'
);
return
repository
.
getUrl
()
+
dir
+
"/"
;
}
public
URL
getFileURL
(
String
version
)
throws
MalformedURLException
{
String
fileURL
=
getArtifactDir
()
+
version
+
"/"
+
artifactId
+
".jar"
;
return
new
URL
(
fileURL
);
}
@Override
public
String
toString
()
{
return
groupId
+
":"
+
artifactId
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRegistry.java
0 → 100644
浏览文件 @
2236f9a6
/*
* 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.registry.maven
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.eclipse.core.runtime.IExtensionRegistry
;
import
org.eclipse.core.runtime.Platform
;
import
org.jkiss.dbeaver.Log
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
MavenRegistry
{
static
final
Log
log
=
Log
.
getLog
(
MavenRegistry
.
class
);
private
static
MavenRegistry
instance
=
null
;
public
synchronized
static
MavenRegistry
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
MavenRegistry
();
instance
.
loadExtensions
(
Platform
.
getExtensionRegistry
());
}
return
instance
;
}
private
final
List
<
MavenRepository
>
repositories
=
new
ArrayList
<
MavenRepository
>();
private
MavenRegistry
()
{
}
public
void
loadExtensions
(
IExtensionRegistry
registry
)
{
// Load data type providers from external plugins
{
IConfigurationElement
[]
extElements
=
registry
.
getConfigurationElementsFor
(
MavenRepository
.
EXTENSION_ID
);
for
(
IConfigurationElement
ext
:
extElements
)
{
MavenRepository
repository
=
new
MavenRepository
(
ext
);
repositories
.
add
(
repository
);
}
}
}
public
List
<
MavenRepository
>
getRepositories
()
{
return
repositories
;
}
public
MavenArtifact
findArtifact
(
String
mavenUri
)
{
int
divPos
=
mavenUri
.
indexOf
(
'/'
);
if
(
divPos
<
0
)
{
log
.
warn
(
"Bad maven uri: "
+
mavenUri
);
return
null
;
}
mavenUri
=
mavenUri
.
substring
(
divPos
+
1
);
divPos
=
mavenUri
.
indexOf
(
':'
);
if
(
divPos
<
0
)
{
log
.
warn
(
"Bad maven uri, no group id: "
+
mavenUri
);
return
null
;
}
String
groupId
=
mavenUri
.
substring
(
0
,
divPos
);
int
divPos2
=
mavenUri
.
indexOf
(
':'
,
divPos
+
1
);
if
(
divPos2
<
0
)
{
log
.
warn
(
"Bad maven uri, no artifact id: "
+
mavenUri
);
return
null
;
}
String
artifactId
=
mavenUri
.
substring
(
divPos
+
1
,
divPos2
);
return
findArtifact
(
groupId
,
artifactId
);
}
public
MavenArtifact
findArtifact
(
String
groupId
,
String
artifactId
)
{
for
(
MavenRepository
repository
:
repositories
)
{
MavenArtifact
artifact
=
repository
.
getArtifact
(
groupId
,
artifactId
);
if
(
artifact
!=
null
)
{
return
artifact
;
}
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenRepository.java
0 → 100644
浏览文件 @
2236f9a6
/*
* 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.registry.maven
;
import
org.eclipse.core.runtime.IConfigurationElement
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverActivator
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
java.io.File
;
import
java.io.IOException
;
/**
* Maven repository manager.
*/
public
class
MavenRepository
{
static
final
Log
log
=
Log
.
getLog
(
MavenRepository
.
class
);
public
static
final
String
EXTENSION_ID
=
"org.jkiss.dbeaver.mavenRepository"
;
private
String
id
;
private
String
name
;
private
String
url
;
public
MavenRepository
(
IConfigurationElement
config
)
{
this
.
id
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_ID
);
this
.
name
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_NAME
);
this
.
url
=
config
.
getAttribute
(
RegistryConstants
.
ATTR_URL
);
}
public
String
getName
()
{
return
name
;
}
public
String
getUrl
()
{
return
url
;
}
public
MavenArtifact
getArtifact
(
String
groupId
,
String
artifactId
)
{
try
{
return
new
MavenArtifact
(
this
,
groupId
,
artifactId
);
}
catch
(
IOException
e
)
{
log
.
debug
(
e
);
return
null
;
}
}
public
File
getCacheLocation
()
{
File
homeFolder
=
new
File
(
DBeaverActivator
.
getInstance
().
getStateLocation
().
toFile
(),
"maven/"
+
id
+
"/cache"
);
if
(!
homeFolder
.
exists
())
{
if
(!
homeFolder
.
mkdirs
())
{
log
.
warn
(
"Can't create maven repository '"
+
name
+
"' cache folder '"
+
homeFolder
+
"'"
);
}
}
return
homeFolder
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录