public final class SimpleCompositeCommandHandler extends Object implements CommandHandler, ReplyTextBundleAware
The following example replaces the CWD CommandHandler with a SimpleCompositeCommandHandler.
The first invocation of the CWD command will fail (reply code 500). The seconds will succeed.
StubFtpServer stubFtpServer = new StubFtpServer();
CommandHandler commandHandler1 = new StaticReplyCommandHandler(500);
CommandHandler commandHandler2 = new CwdCommandHandler();
SimpleCompositeCommandHandler simpleCompositeCommandHandler = new SimpleCompositeCommandHandler();
simpleCompositeCommandHandler.addCommandHandler(commandHandler1);
simpleCompositeCommandHandler.addCommandHandler(commandHandler2);
stubFtpServer.setCommandHandler("CWD", simpleCompositeCommandHandler);
| Constructor and Description |
|---|
SimpleCompositeCommandHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCommandHandler(CommandHandler commandHandler)
Add a CommandHandler to the internal list of handlers.
|
CommandHandler |
getCommandHandler(int index)
Return the CommandHandler corresponding to the specified invocation index.
|
ResourceBundle |
getReplyTextBundle()
Returns null.
|
void |
handleCommand(Command command,
Session session)
Handle the specified command for the session.
|
void |
setCommandHandlers(List commandHandlers)
Set the List of CommandHandlers to which to delegate.
|
void |
setReplyTextBundle(ResourceBundle replyTextBundle)
Call
setReplyTextBundle() on each of the command handlers within the internal list. |
public void addCommandHandler(CommandHandler commandHandler)
commandHandler - - the CommandHandlerAssertFailedException - - if the commandHandler is nullpublic void setCommandHandlers(List commandHandlers)
commandHandlers - - the complete List of CommandHandlers to which invocations are delegatedpublic CommandHandler getCommandHandler(int index)
handleCommand(Command, Session) has been or will
be delegated (where N=index).index - - the index of the desired invocation (zero-based).AssertFailedException - - if no CommandHandler is defined for the index or the index is not validpublic void handleCommand(Command command, Session session) throws Exception
CommandHandlerhandleCommand in interface CommandHandlercommand - - the Command to be handledsession - - the session on which the Command was submittedException - - if an error occursCommandHandler.handleCommand(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session)public ResourceBundle getReplyTextBundle()
getReplyTextBundle in interface ReplyTextBundleAwareReplyTextBundleAware.getReplyTextBundle()public void setReplyTextBundle(ResourceBundle replyTextBundle)
setReplyTextBundle() on each of the command handlers within the internal list.setReplyTextBundle in interface ReplyTextBundleAwarereplyTextBundle - - the replyTextBundle to setReplyTextBundleAware.setReplyTextBundle(java.util.ResourceBundle)Copyright © 2016. All rights reserved.