Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1abde6ed
提交
1abde6ed
authored
3月 31, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The FTP server moved to the tools section.
上级
d6383f94
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
137 行增加
和
66 行删除
+137
-66
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Server.java
h2/src/main/org/h2/tools/Server.java
+18
-62
TestFtp.java
h2/src/test/org/h2/test/unit/TestFtp.java
+1
-1
Build.java
h2/src/tools/org/h2/build/Build.java
+1
-0
FtpServer.java
h2/src/tools/org/h2/server/ftp/FtpServer.java
+115
-2
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
1abde6ed
...
@@ -18,7 +18,8 @@ Change Log
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Improved error message for unsupported features:
<ul><li>
The FTP server moved to the tools section and is no longer included in the h2*.jar file.
</li><li>
Improved error message for unsupported features:
now the message says what exactly is not supported.
now the message says what exactly is not supported.
</li><li>
Improved OSGi support.
</li><li>
Improved OSGi support.
</li><li>
Some internal caches did not use the LRU mechanism. Fixed
</li><li>
Some internal caches did not use the LRU mechanism. Fixed
...
...
h2/src/main/org/h2/tools/Server.java
浏览文件 @
1abde6ed
...
@@ -16,27 +16,32 @@ import org.h2.message.TraceSystem;
...
@@ -16,27 +16,32 @@ import org.h2.message.TraceSystem;
import
org.h2.server.Service
;
import
org.h2.server.Service
;
import
org.h2.server.ShutdownHandler
;
import
org.h2.server.ShutdownHandler
;
import
org.h2.server.TcpServer
;
import
org.h2.server.TcpServer
;
import
org.h2.server.ftp.FtpServer
;
import
org.h2.server.pg.PgServer
;
import
org.h2.server.pg.PgServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.util.StartBrowser
;
import
org.h2.util.StartBrowser
;
import
org.h2.util.Tool
;
import
org.h2.util.Tool
;
/**
/**
* Starts the H2 Console (web-) server, TCP,
PG, and FTP
server.
* Starts the H2 Console (web-) server, TCP,
and PG
server.
* @h2.resource
* @h2.resource
*/
*/
public
class
Server
extends
Tool
implements
Runnable
,
ShutdownHandler
{
public
class
Server
extends
Tool
implements
Runnable
,
ShutdownHandler
{
private
Service
service
;
private
Service
service
;
private
Server
web
,
tcp
,
pg
,
ftp
;
private
Server
web
,
tcp
,
pg
;
private
ShutdownHandler
shutdownHandler
;
private
ShutdownHandler
shutdownHandler
;
public
Server
()
{
public
Server
()
{
// nothing to do
// nothing to do
}
}
private
Server
(
Service
service
,
String
[]
args
)
throws
SQLException
{
/**
* Create a new server for the given service.
*
* @param service the service
* @param args the command line arguments
*/
public
Server
(
Service
service
,
String
[]
args
)
throws
SQLException
{
this
.
service
=
service
;
this
.
service
=
service
;
try
{
try
{
service
.
init
(
args
);
service
.
init
(
args
);
...
@@ -46,7 +51,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -46,7 +51,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
}
}
/**
/**
* When running without options, -tcp, -web, -browser and -pg are started.<br />
* When running without options, -tcp, -web, -browser and -pg are started.
* <br />
* Options are case sensitive. Supported options are:
* Options are case sensitive. Supported options are:
* <table>
* <table>
* <tr><td>[-help] or [-?]</td>
* <tr><td>[-help] or [-?]</td>
...
@@ -81,18 +87,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -81,18 +87,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* <td>Allow other computers to connect</td></tr>
* <td>Allow other computers to connect</td></tr>
* <tr><td>[-pgPort <port>]</td>
* <tr><td>[-pgPort <port>]</td>
* <td>The port (default: 5435)</td></tr>
* <td>The port (default: 5435)</td></tr>
* <tr><td>[-ftp]</td>
* <td>Start the FTP server</td></tr>
* <tr><td>[-ftpPort <port>]</td>
* <td>The port (default: 8021)</td></tr>
* <tr><td>[-ftpDir <dir>]</td>
* <td>The base directory (default: ftp)</td></tr>
* <tr><td>[-ftpRead <user>]</td>
* <td>The user name for reading (default: guest)</td></tr>
* <tr><td>[-ftpWrite <user>]</td>
* <td>The user name for writing (default: sa)</td></tr>
* <tr><td>[-ftpWritePassword <p>]</td>
* <td>The write password (default: sa)</td></tr>
* <tr><td>[-baseDir <dir>]</td>
* <tr><td>[-baseDir <dir>]</td>
* <td>The base directory for H2 databases; for all servers</td></tr>
* <td>The base directory for H2 databases; for all servers</td></tr>
* <tr><td>[-ifExists]</td>
* <tr><td>[-ifExists]</td>
...
@@ -109,7 +103,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -109,7 +103,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
}
}
public
void
run
(
String
[]
args
)
throws
SQLException
{
public
void
run
(
String
[]
args
)
throws
SQLException
{
boolean
tcpStart
=
false
,
pgStart
=
false
,
webStart
=
false
,
ftpStart
=
false
;
boolean
tcpStart
=
false
,
pgStart
=
false
,
webStart
=
false
;
boolean
browserStart
=
false
;
boolean
browserStart
=
false
;
boolean
tcpShutdown
=
false
,
tcpShutdownForce
=
false
;
boolean
tcpShutdown
=
false
,
tcpShutdownForce
=
false
;
String
tcpPassword
=
""
;
String
tcpPassword
=
""
;
...
@@ -187,25 +181,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -187,25 +181,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
}
else
{
}
else
{
throwUnsupportedOption
(
arg
);
throwUnsupportedOption
(
arg
);
}
}
}
else
if
(
arg
.
startsWith
(
"-ftp"
))
{
if
(
"-ftp"
.
equals
(
arg
))
{
startDefaultServers
=
false
;
ftpStart
=
true
;
}
else
if
(
"-ftpPort"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpDir"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpRead"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpWrite"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpWritePassword"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpTask"
.
equals
(
arg
))
{
// no parameters
}
else
{
throwUnsupportedOption
(
arg
);
}
}
else
if
(
"-trace"
.
equals
(
arg
))
{
}
else
if
(
"-trace"
.
equals
(
arg
))
{
// no parameters
// no parameters
}
else
if
(
"-log"
.
equals
(
arg
)
&&
SysProperties
.
OLD_COMMAND_LINE_OPTIONS
)
{
}
else
if
(
"-log"
.
equals
(
arg
)
&&
SysProperties
.
OLD_COMMAND_LINE_OPTIONS
)
{
...
@@ -261,11 +236,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -261,11 +236,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
pg
.
start
();
pg
.
start
();
out
.
println
(
pg
.
getStatus
());
out
.
println
(
pg
.
getStatus
());
}
}
if
(
ftpStart
)
{
ftp
=
createFtpServer
(
args
);
ftp
.
start
();
out
.
println
(
ftp
.
getStatus
());
}
}
}
/**
/**
...
@@ -290,7 +260,12 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -290,7 +260,12 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
TcpServer
.
shutdown
(
url
,
password
,
force
);
TcpServer
.
shutdown
(
url
,
password
,
force
);
}
}
String
getStatus
()
{
/**
* Get the status of this server.
*
* @return the status
*/
public
String
getStatus
()
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
if
(
isRunning
(
false
))
{
if
(
isRunning
(
false
))
{
buff
.
append
(
service
.
getType
());
buff
.
append
(
service
.
getType
());
...
@@ -328,21 +303,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -328,21 +303,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
return
server
;
return
server
;
}
}
/**
* Create a new ftp server, but does not start it yet. Example:
*
* <pre>
* Server server = Server.createFtpServer(
* new String[] { "-trace" }).start();
* </pre>
*
* @param args the argument list
* @return the server
*/
public
static
Server
createFtpServer
(
String
[]
args
)
throws
SQLException
{
return
new
Server
(
new
FtpServer
(),
args
);
}
/**
/**
* Create a new TCP server, but does not start it yet. Example:
* Create a new TCP server, but does not start it yet. Example:
*
*
...
@@ -420,10 +380,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
...
@@ -420,10 +380,6 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
pg
.
stop
();
pg
.
stop
();
pg
=
null
;
pg
=
null
;
}
}
if
(
ftp
!=
null
&&
ftp
.
isRunning
(
false
))
{
ftp
.
stop
();
ftp
=
null
;
}
}
}
/**
/**
...
...
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
1abde6ed
...
@@ -33,7 +33,7 @@ public class TestFtp extends TestBase implements FtpEventListener {
...
@@ -33,7 +33,7 @@ public class TestFtp extends TestBase implements FtpEventListener {
}
}
private
void
test
(
String
dir
)
throws
Exception
{
private
void
test
(
String
dir
)
throws
Exception
{
Server
server
=
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
,
"-ftpPort"
,
"8121"
}).
start
();
Server
server
=
Ftp
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
,
"-ftpPort"
,
"8121"
}).
start
();
FtpServer
ftp
=
(
FtpServer
)
server
.
getService
();
FtpServer
ftp
=
(
FtpServer
)
server
.
getService
();
ftp
.
setEventListener
(
this
);
ftp
.
setEventListener
(
this
);
FtpClient
client
=
FtpClient
.
open
(
"localhost:8121"
);
FtpClient
client
=
FtpClient
.
open
(
"localhost:8121"
);
...
...
h2/src/tools/org/h2/build/Build.java
浏览文件 @
1abde6ed
...
@@ -241,6 +241,7 @@ public class Build extends BuildBase {
...
@@ -241,6 +241,7 @@ public class Build extends BuildBase {
exclude
(
"temp/org/h2/jaqu/*"
).
exclude
(
"temp/org/h2/jaqu/*"
).
exclude
(
"temp/org/h2/mode/*"
).
exclude
(
"temp/org/h2/mode/*"
).
exclude
(
"temp/org/h2/samples/*"
).
exclude
(
"temp/org/h2/samples/*"
).
exclude
(
"temp/org/h2/server/ftp/*"
).
exclude
(
"temp/org/h2/test/*"
).
exclude
(
"temp/org/h2/test/*"
).
exclude
(
"*.bat"
).
exclude
(
"*.bat"
).
exclude
(
"*.sh"
).
exclude
(
"*.sh"
).
...
...
h2/src/tools/org/h2/server/ftp/FtpServer.java
浏览文件 @
1abde6ed
...
@@ -18,10 +18,10 @@ import java.util.Date;
...
@@ -18,10 +18,10 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.server.Service
;
import
org.h2.server.Service
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.tools.Server
;
import
org.h2.util.FileUtils
;
import
org.h2.util.FileUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
...
@@ -34,7 +34,7 @@ import org.h2.util.Tool;
...
@@ -34,7 +34,7 @@ import org.h2.util.Tool;
* Remote connections are possible.
* Remote connections are possible.
* See also http://cr.yp.to/ftp.html http://www.ftpguide.com/
* See also http://cr.yp.to/ftp.html http://www.ftpguide.com/
*/
*/
public
class
FtpServer
implements
Service
{
public
class
FtpServer
extends
Tool
implements
Service
{
/**
/**
* The default port to use for the FTP server.
* The default port to use for the FTP server.
...
@@ -88,6 +88,105 @@ public class FtpServer implements Service {
...
@@ -88,6 +88,105 @@ public class FtpServer implements Service {
private
FtpEventListener
eventListener
;
private
FtpEventListener
eventListener
;
/**
* When running without options, -tcp, -web, -browser and -pg are started.<br />
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-web]</td>
* <td>Start the web server with the H2 Console</td></tr>
* <tr><td>[-webAllowOthers]</td>
* <td>Allow other computers to connect</td></tr>
* <tr><td>[-webPort <port>]</td>
* <td>The port (default: 8082)</td></tr>
* <tr><td>[-webSSL]</td>
* <td>Use encrypted (HTTPS) connections</td></tr>
* <tr><td>[-browser]</td>
* <td>Start a browser and open a page to connect to the web server</td></tr>
* <tr><td>[-tcp]</td>
* <td>Start the TCP server</td></tr>
* <tr><td>[-tcpAllowOthers]</td>
* <td>Allow other computers to connect</td></tr>
* <tr><td>[-tcpPort <port>]</td>
* <td>The port (default: 9092)</td></tr>
* <tr><td>[-tcpSSL]</td>
* <td>Use encrypted (SSL) connections</td></tr>
* <tr><td>[-tcpPassword <pwd>]</td>
* <td>The password for shutting down a TCP server</td></tr>
* <tr><td>[-tcpShutdown <url>]</td>
* <td>Stop the TCP server; example: tcp://localhost:9094</td></tr>
* <tr><td>[-tcpShutdownForce]</td>
* <td>Do not wait until all connections are closed</td></tr>
* <tr><td>[-pg]</td>
* <td>Start the PG server</td></tr>
* <tr><td>[-pgAllowOthers]</td>
* <td>Allow other computers to connect</td></tr>
* <tr><td>[-pgPort <port>]</td>
* <td>The port (default: 5435)</td></tr>
* <tr><td>[-ftp]</td>
* <td>Start the FTP server</td></tr>
* <tr><td>[-ftpPort <port>]</td>
* <td>The port (default: 8021)</td></tr>
* <tr><td>[-ftpDir <dir>]</td>
* <td>The base directory (default: ftp)</td></tr>
* <tr><td>[-ftpRead <user>]</td>
* <td>The user name for reading (default: guest)</td></tr>
* <tr><td>[-ftpWrite <user>]</td>
* <td>The user name for writing (default: sa)</td></tr>
* <tr><td>[-ftpWritePassword <p>]</td>
* <td>The write password (default: sa)</td></tr>
* <tr><td>[-baseDir <dir>]</td>
* <td>The base directory for H2 databases; for all servers</td></tr>
* <tr><td>[-ifExists]</td>
* <td>Only existing databases may be opened; for all servers</td></tr>
* <tr><td>[-trace]</td>
* <td>Print additional trace information; for all servers</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
new
FtpServer
().
run
(
args
);
}
public
void
run
(
String
[]
args
)
throws
SQLException
{
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
length
;
i
++)
{
String
arg
=
args
[
i
];
if
(
arg
==
null
)
{
continue
;
}
else
if
(
"-?"
.
equals
(
arg
)
||
"-help"
.
equals
(
arg
))
{
showUsage
();
return
;
}
else
if
(
arg
.
startsWith
(
"-ftp"
))
{
if
(
"-ftpPort"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpDir"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpRead"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpWrite"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpWritePassword"
.
equals
(
arg
))
{
i
++;
}
else
if
(
"-ftpTask"
.
equals
(
arg
))
{
// no parameters
}
else
{
throwUnsupportedOption
(
arg
);
}
}
else
if
(
"-trace"
.
equals
(
arg
))
{
// no parameters
}
else
{
throwUnsupportedOption
(
arg
);
}
}
Server
server
=
new
Server
(
this
,
args
);
server
.
start
();
out
.
println
(
server
.
getStatus
());
}
public
void
listen
()
{
public
void
listen
()
{
try
{
try
{
while
(
serverSocket
!=
null
)
{
while
(
serverSocket
!=
null
)
{
...
@@ -448,4 +547,18 @@ public class FtpServer implements Service {
...
@@ -448,4 +547,18 @@ public class FtpServer implements Service {
return
eventListener
;
return
eventListener
;
}
}
/**
* Create a new FTP server, but does not start it yet. Example:
*
* <pre>
* Server server = FtpServer.createFtpServer(null).start();
* </pre>
*
* @param args the argument list
* @return the server
*/
public
static
Server
createFtpServer
(
String
[]
args
)
throws
SQLException
{
return
new
Server
(
new
FtpServer
(),
args
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论