|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockftpserver.core.server.AbstractFtpServer
public abstract class AbstractFtpServer
This is the abstract superclass for "mock" implementations of an FTP Server,
suitable for testing FTP client code or standing in for a live FTP server. It supports
the main FTP commands by defining handlers for each of the corresponding low-level FTP
server commands (e.g. RETR, DELE, LIST). These handlers implement the CommandHandler
interface.
serverControlPort property. If you specify a value of 0,
then a free port number will be chosen automatically; call getServerControlPort() AFTER
start() has been called to determine the actual port number being used. Using a non-default
port number is usually necessary when running on Unix or some other system where that port number is
already in use or cannot be bound from a user process.
CommandHandler defined for an FTP server command
by calling the setCommandHandler(String, CommandHandler) method, passing
in the FTP server command name and CommandHandler instance.
You can also replace multiple command handlers at once by using the setCommandHandlers(Map)
method. That is especially useful when configuring the server through the Spring Framework.
You can retrieve the existing CommandHandler defined for an FTP server command by
calling the getCommandHandler(String) method, passing in the FTP server command name.
setReplyTextBaseName(String) method.
FakeFtpServer,
StubFtpServer| Field Summary | |
|---|---|
protected org.slf4j.Logger |
LOG
|
static String |
REPLY_TEXT_BASENAME
Default basename for reply text ResourceBundle |
protected ServerSocketFactory |
serverSocketFactory
|
| Constructor Summary | |
|---|---|
AbstractFtpServer()
Create a new instance. |
|
| Method Summary | |
|---|---|
protected Session |
createSession(Socket clientSocket)
Create a new Session instance for the specified client Socket |
CommandHandler |
getCommandHandler(String name)
Return the CommandHandler defined for the specified command name |
ResourceBundle |
getReplyTextBundle()
Return the ReplyText ResourceBundle. |
int |
getServerControlPort()
Return the port number to which the server control connection socket will bind. |
protected abstract void |
initializeCommandHandler(CommandHandler commandHandler)
Initialize a CommandHandler that has been registered to this server. |
boolean |
isShutdown()
Return true if this server is fully shutdown -- i.e., there is no active (alive) threads and all sockets are closed. |
boolean |
isStarted()
Return true if this server has started -- i.e., there is an active (alive) server threads and non-null server socket. |
void |
run()
The logic for the server thread |
void |
setCommandHandler(String commandName,
CommandHandler commandHandler)
Set the CommandHandler for the specified command name. |
void |
setCommandHandlers(Map commandHandlerMapping)
Override the default CommandHandlers with those in the specified Map of commandName>>CommandHandler. |
void |
setReplyTextBaseName(String baseName)
Set the reply text ResourceBundle to a new ResourceBundle with the specified base name, accessible on the CLASSPATH. |
void |
setServerControlPort(int serverControlPort)
Set the port number to which the server control connection socket will bind. |
void |
start()
Start a new Thread for this server instance |
void |
stop()
Stop this server instance and wait for it to terminate. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String REPLY_TEXT_BASENAME
protected org.slf4j.Logger LOG
protected ServerSocketFactory serverSocketFactory
| Constructor Detail |
|---|
public AbstractFtpServer()
| Method Detail |
|---|
public void start()
public void run()
run in interface RunnableRunnable.run()public void stop()
public CommandHandler getCommandHandler(String name)
name - - the command name
public void setCommandHandlers(Map commandHandlerMapping)
commandHandlerMapping. All other default CommandHandler
mappings remain unchanged.
commandHandlerMapping - - the Map of commandName->CommandHandler; these override the defaults
AssertFailedException - - if the commandHandlerMapping is null
public void setCommandHandler(String commandName,
CommandHandler commandHandler)
ReplyTextBundleAware interface and its replyTextBundle attribute
is null, then set its replyTextBundle to the replyTextBundle of
this StubFtpServer.
commandName - - the command name to which the CommandHandler will be associatedcommandHandler - - the CommandHandler
AssertFailedException - - if the commandName or commandHandler is nullpublic void setReplyTextBaseName(String baseName)
ResourceBundle.getBundle(String).
baseName - - the base name of the resource bundle, a fully qualified class namepublic ResourceBundle getReplyTextBundle()
setReplyTextBaseName(String) method.
public void setServerControlPort(int serverControlPort)
serverControlPort - - the port number for the server control connection ServerSocketpublic int getServerControlPort()
public boolean isShutdown()
public boolean isStarted()
protected Session createSession(Socket clientSocket)
clientSocket - - the Socket associated with the client
protected abstract void initializeCommandHandler(CommandHandler commandHandler)
commandHandler - - the CommandHandler to initialize
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||