Package org.h2.dev.ftp.server
Class FtpServer
- java.lang.Object
-
- org.h2.util.Tool
-
- org.h2.dev.ftp.server.FtpServer
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PORTThe default port to use for the FTP server.static java.lang.StringDEFAULT_READThe default user name that is allowed to read data.static java.lang.StringDEFAULT_ROOTThe default root directory name used by the FTP server.static java.lang.StringDEFAULT_WRITEThe default user name that is allowed to read and write data.static java.lang.StringDEFAULT_WRITE_PASSWORDThe default password of the user that is allowed to read and write data.
-
Constructor Summary
Constructors Constructor Description FtpServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServercreateFtpServer(java.lang.String... args)Create a new FTP server, but does not start it yet.booleangetAllowOthers()Check if remote connections are allowed.java.lang.StringgetName()Get the human readable name of the service.intgetPort()Gets the port this service is listening on.java.lang.StringgetType()Get the human readable short name of the service.java.lang.StringgetURL()Get the URL of this service in a human readable formvoidinit(java.lang.String... args)Initialize the service from command line options.booleanisDaemon()Check if a daemon thread should be used.booleanisRunning(boolean traceError)Check if the service is running.voidlisten()Listen for incoming connections.static voidmain(java.lang.String... args)When running without options, -tcp, -web, -browser, and -pg are started.voidrunTool(java.lang.String... args)Run the tool with the given output stream and arguments.voidsetEventListener(FtpEventListener eventListener)Set the event listener.voidstart()Start the service.voidstop()Stop the service.-
Methods inherited from class org.h2.util.Tool
getMainClassName, isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
-
-
-
Field Detail
-
DEFAULT_PORT
public static final int DEFAULT_PORT
The default port to use for the FTP server. This value is also in the documentation and in the Server javadoc.- See Also:
- Constant Field Values
-
DEFAULT_ROOT
public static final java.lang.String DEFAULT_ROOT
The default root directory name used by the FTP server. This value is also in the documentation and in the Server javadoc.- See Also:
- Constant Field Values
-
DEFAULT_READ
public static final java.lang.String DEFAULT_READ
The default user name that is allowed to read data. This value is also in the documentation and in the Server javadoc.- See Also:
- Constant Field Values
-
DEFAULT_WRITE
public static final java.lang.String DEFAULT_WRITE
The default user name that is allowed to read and write data. This value is also in the documentation and in the Server javadoc.- See Also:
- Constant Field Values
-
DEFAULT_WRITE_PASSWORD
public static final java.lang.String DEFAULT_WRITE_PASSWORD
The default password of the user that is allowed to read and write data. This value is also in the documentation and in the Server javadoc.- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.sql.SQLExceptionWhen running without options, -tcp, -web, -browser, and -pg are started. Options are case sensitive.Supported options [-help] or [-?] Print the list of options [-web] Start the web server with the H2 Console [-webAllowOthers] Allow other computers to connect [-webPort <port>] The port (default: 8082) [-webSSL] Use encrypted (HTTPS) connections [-browser] Start a browser and open a page to login to the web server [-tcp] Start the TCP server [-tcpAllowOthers] Allow other computers to connect [-tcpPort <port>] The port (default: 9092) [-tcpSSL] Use encrypted (SSL) connections [-tcpPassword <pwd>] The password for shutting down a TCP server [-tcpShutdown "<url>"] Stop the TCP server; example: tcp://localhost:9094 [-tcpShutdownForce] Do not wait until all connections are closed [-pg] Start the PG server [-pgAllowOthers] Allow other computers to connect [-pgPort <port>] The port (default: 5435) [-ftp] Start the FTP server [-ftpPort <port>] The port (default: 8021) [-ftpDir <dir>] The base directory (default: ftp) [-ftpRead <user>] The user name for reading (default: guest) [-ftpWrite <user>] The user name for writing (default: sa) [-ftpWritePassword <p>] The write password (default: sa) [-baseDir <dir>] The base directory for H2 databases; for all servers [-ifExists] Only existing databases may be opened; for all servers [-trace] Print additional trace information; for all servers - Parameters:
args- the command line arguments- Throws:
java.sql.SQLException
-
runTool
public void runTool(java.lang.String... args) throws java.sql.SQLExceptionDescription copied from class:ToolRun the tool with the given output stream and arguments.
-
listen
public void listen()
Description copied from interface:ServiceListen for incoming connections. This method blocks.
-
init
public void init(java.lang.String... args)
Description copied from interface:ServiceInitialize the service from command line options.
-
getURL
public java.lang.String getURL()
Description copied from interface:ServiceGet the URL of this service in a human readable form
-
getPort
public int getPort()
Description copied from interface:ServiceGets the port this service is listening on.
-
start
public void start()
Description copied from interface:ServiceStart the service. This usually means create the server socket. This method must not block.
-
stop
public void stop()
Description copied from interface:ServiceStop the service.
-
isRunning
public boolean isRunning(boolean traceError)
Description copied from interface:ServiceCheck if the service is running.
-
getAllowOthers
public boolean getAllowOthers()
Description copied from interface:ServiceCheck if remote connections are allowed.- Specified by:
getAllowOthersin interfaceService- Returns:
- true if remote connections are allowed
-
getType
public java.lang.String getType()
Description copied from interface:ServiceGet the human readable short name of the service.
-
getName
public java.lang.String getName()
Description copied from interface:ServiceGet the human readable name of the service.
-
setEventListener
public void setEventListener(FtpEventListener eventListener)
Set the event listener. Only one listener can be registered.- Parameters:
eventListener- the new listener, or null to de-register
-
createFtpServer
public static Server createFtpServer(java.lang.String... args) throws java.sql.SQLException
Create a new FTP server, but does not start it yet. Example:Server server = FtpServer.createFtpServer(null).start();
- Parameters:
args- the argument list- Returns:
- the server
- Throws:
java.sql.SQLException
-
-