|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockftpserver.core.command.SimpleCompositeCommandHandler
public final class SimpleCompositeCommandHandler
Composite CommandHandler that manages an internal list of CommandHandlers to which it delegates. The internal CommandHandlers are maintained in an ordered list. Starting with the first CommandHandler in the list, each invocation of this composite handler will invoke (delegate to) the current internal CommandHander. Then it moves on the next CommandHandler in the internal list.
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 Summary | |
|---|---|
SimpleCompositeCommandHandler()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleCompositeCommandHandler()
| Method Detail |
|---|
public void addCommandHandler(CommandHandler commandHandler)
commandHandler - - the CommandHandler
AssertFailedException - - 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 valid
public void handleCommand(Command command,
Session session)
throws Exception
CommandHandler
handleCommand in interface CommandHandlercommand - - the Command to be handledsession - - the session on which the Command was submitted
ExceptionCommandHandler.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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||