Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
adc476c7
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,发现更多精彩内容 >>
提交
adc476c7
编写于
5月 20, 2016
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RMI server
上级
5ddfc091
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
21 deletion
+63
-21
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
...rg/jkiss/dbeaver/core/application/DBeaverApplication.java
+38
-18
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/IInstanceController.java
...rc/org/jkiss/dbeaver/runtime/rmi/IInstanceController.java
+1
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/InstanceClient.java
...ore/src/org/jkiss/dbeaver/runtime/rmi/InstanceClient.java
+22
-2
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/InstanceServer.java
...ore/src/org/jkiss/dbeaver/runtime/rmi/InstanceServer.java
+1
-1
未找到文件。
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
浏览文件 @
adc476c7
...
...
@@ -32,10 +32,14 @@ import org.eclipse.ui.PlatformUI;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.runtime.rmi.IInstanceController
;
import
org.jkiss.dbeaver.runtime.rmi.InstanceClient
;
import
org.jkiss.dbeaver.runtime.rmi.InstanceServer
;
import
org.jkiss.utils.ArrayUtils
;
import
java.io.File
;
import
java.net.URL
;
import
java.rmi.RemoteException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
...
...
@@ -57,15 +61,12 @@ public class DBeaverApplication implements IApplication
Location
instanceLoc
=
Platform
.
getInstanceLocation
();
String
defaultHomePath
=
getDefaultWorkspaceLocation
().
getAbsolutePath
();
try
{
URL
defaultHomeURL
=
new
URL
(
"file"
,
//$NON-NLS-1$
null
,
defaultHomePath
);
URL
defaultHomeURL
=
new
File
(
defaultHomePath
).
toURI
().
toURL
();
boolean
keepTrying
=
true
;
Shell
shell
=
null
;
while
(
keepTrying
)
{
if
(!
instanceLoc
.
set
(
defaultHomeURL
,
true
))
{
if
(
handleCommandLine
(
instanceLoc
))
{
if
(
handleCommandLine
(
defaultHomePath
))
{
return
IApplication
.
EXIT_OK
;
}
// Can't lock specified path
...
...
@@ -131,11 +132,38 @@ public class DBeaverApplication implements IApplication
}
}
private
boolean
handleCommandLine
(
Location
instanceLoc
)
{
private
boolean
handleCommandLine
(
String
instanceLoc
)
{
CommandLine
commandLine
=
getCommandLine
();
if
(
commandLine
==
null
)
{
return
false
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_HELP
))
{
HelpFormatter
helpFormatter
=
new
HelpFormatter
();
helpFormatter
.
setWidth
(
120
);
helpFormatter
.
setOptionComparator
(
new
Comparator
<
Option
>()
{
@Override
public
int
compare
(
Option
o1
,
Option
o2
)
{
return
0
;
}
});
helpFormatter
.
printHelp
(
"dbeaver"
,
DBeaverCore
.
getProductTitle
(),
DBeaverCommandLine
.
ALL_OPTIONS
,
"(C) 2016 JKISS"
,
true
);
return
true
;
}
try
{
IInstanceController
controller
=
InstanceClient
.
createClient
(
instanceLoc
);
if
(
controller
==
null
)
{
return
false
;
}
return
callRemoteServer
(
commandLine
,
controller
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"Error calling remote server"
,
e
);
return
false
;
}
}
private
boolean
callRemoteServer
(
CommandLine
commandLine
,
IInstanceController
controller
)
throws
RemoteException
{
String
[]
files
=
commandLine
.
getOptionValues
(
DBeaverCommandLine
.
PARAM_FILE
);
String
[]
fileArgs
=
commandLine
.
getArgs
();
if
(!
ArrayUtils
.
isEmpty
(
files
)
||
!
ArrayUtils
.
isEmpty
(
fileArgs
))
{
...
...
@@ -146,24 +174,16 @@ public class DBeaverApplication implements IApplication
if
(!
ArrayUtils
.
isEmpty
(
fileArgs
))
{
Collections
.
addAll
(
fileNames
,
fileArgs
);
}
controller
.
openExternalFiles
(
fileNames
.
toArray
(
new
String
[
fileNames
.
size
()]));
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_STOP
))
{
controller
.
quit
();
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_THREAD_DUMP
))
{
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_HELP
))
{
HelpFormatter
helpFormatter
=
new
HelpFormatter
();
helpFormatter
.
setWidth
(
120
);
helpFormatter
.
setOptionComparator
(
new
Comparator
<
Option
>()
{
@Override
public
int
compare
(
Option
o1
,
Option
o2
)
{
return
0
;
}
});
helpFormatter
.
printHelp
(
"dbeaver"
,
"Universal Database Manager"
,
DBeaverCommandLine
.
ALL_OPTIONS
,
"(C) 2016 Serge Rider"
,
true
);
String
threadDump
=
controller
.
getThreadDump
();
System
.
out
.
println
(
threadDump
);
return
true
;
}
return
false
;
...
...
plugins/org.jkiss.dbeaver.core/META-INF/MANIFEST.MF
浏览文件 @
adc476c7
...
...
@@ -23,6 +23,7 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.runtime.net,
org.jkiss.dbeaver.runtime.properties,
org.jkiss.dbeaver.runtime.qm,
org.jkiss.dbeaver.runtime.rmi,
org.jkiss.dbeaver.runtime.sql,
org.jkiss.dbeaver.runtime.ui,
org.jkiss.dbeaver.tools,
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/IInstanceController.java
浏览文件 @
adc476c7
...
...
@@ -27,6 +27,7 @@ import java.rmi.RemoteException;
public
interface
IInstanceController
extends
Remote
{
public
static
final
String
CONTROLLER_ID
=
"DBeaver.InstanceController"
;
public
static
final
String
RMI_PROP_FILE
=
".dbeaver-server.properties"
;
String
getVersion
()
throws
RemoteException
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/InstanceClient.java
浏览文件 @
adc476c7
...
...
@@ -18,12 +18,32 @@
package
org.jkiss.dbeaver.runtime.rmi
;
import
org.jkiss.dbeaver.Log
;
import
java.io.*
;
import
java.net.URL
;
import
java.rmi.registry.LocateRegistry
;
import
java.util.Properties
;
/**
*
DBeaver instance controller.
*
InstanceClient
*/
public
class
InstanceClient
{
public
static
IInstanceController
createClient
()
{
private
static
final
Log
log
=
Log
.
getLog
(
InstanceClient
.
class
);
public
static
IInstanceController
createClient
(
String
location
)
{
try
{
File
rmiFile
=
new
File
(
location
,
".metadata/"
+
IInstanceController
.
RMI_PROP_FILE
);
Properties
props
=
new
Properties
();
try
(
InputStream
is
=
new
FileInputStream
(
rmiFile
))
{
props
.
load
(
is
);
}
String
rmiPort
=
props
.
getProperty
(
"port"
);
return
(
IInstanceController
)
LocateRegistry
.
getRegistry
(
Integer
.
parseInt
(
rmiPort
)).
lookup
(
IInstanceController
.
CONTROLLER_ID
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error reading RMI config"
,
e
);
}
return
null
;
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/rmi/InstanceServer.java
浏览文件 @
adc476c7
...
...
@@ -37,7 +37,7 @@ import java.util.Properties;
public
class
InstanceServer
implements
IInstanceController
{
private
static
final
Log
log
=
Log
.
getLog
(
InstanceServer
.
class
);
private
static
final
String
RMI_PROP_FILE
=
".dbeaver-server.properties"
;
private
static
int
portNumber
;
private
static
Registry
registry
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录