public abstract class AbstractStubDataCommandHandler extends AbstractTrackingCommandHandler implements CommandHandler
Return two replies on the control connection: by default a reply code of 150 before the data transfer across the data connection and another reply of 226 after the data transfer is complete.
This class implements the Template Method pattern. Subclasses must implement the abstract
processData
method to perform read or writes across the data connection.
Subclasses can optionally override the beforeProcessData(Command, Session, InvocationRecord)
method for logic before the data transfer or the afterProcessData(Command, Session, InvocationRecord)
method for logic after the data transfer.
Subclasses can optionally override the reply code and/or text for the initial reply (before
the data transfer across the data connection) by calling setPreliminaryReplyCode(int)
,
setPreliminaryReplyMessageKey(String)
and/or setPreliminaryReplyText(String)
methods.
Subclasses can optionally override the reply code and/or text for the final reply (after the
the data transfer is complete) by calling setFinalReplyCode(int)
,
setFinalReplyMessageKey(String)
and/or setFinalReplyText(String)
methods.
Modifier and Type | Field and Description |
---|---|
protected int |
finalReplyCode |
protected String |
finalReplyMessageKey |
protected String |
finalReplyText |
protected int |
preliminaryReplyCode |
protected String |
preliminaryReplyMessageKey |
protected String |
preliminaryReplyText |
LOG
Modifier | Constructor and Description |
---|---|
protected |
AbstractStubDataCommandHandler()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterProcessData(Command command,
Session session,
InvocationRecord invocationRecord)
Perform any necessary logic after transferring data across the data connection.
|
protected void |
beforeProcessData(Command command,
Session session,
InvocationRecord invocationRecord)
Perform any necessary logic before transferring data across the data connection.
|
void |
handleCommand(Command command,
Session session,
InvocationRecord invocationRecord)
Handle the command.
|
protected abstract void |
processData(Command command,
Session session,
InvocationRecord invocationRecord)
Abstract method placeholder for subclass transfer of data across the data connection.
|
protected void |
sendFinalReply(Session session)
Send the final reply.
|
void |
setFinalReplyCode(int finalReplyCode)
Set the completion reply code sent after data transfer
|
void |
setFinalReplyMessageKey(String finalReplyMessageKey)
Set the message key for the completion reply text sent after data transfer
|
void |
setFinalReplyText(String finalReplyText)
Set the text of the completion reply sent after data transfer
|
void |
setPreliminaryReplyCode(int preliminaryReplyCode)
Set the completion reply code sent before data transfer
|
void |
setPreliminaryReplyMessageKey(String preliminaryReplyMessageKey)
Set the message key for the completion reply text sent before data transfer
|
void |
setPreliminaryReplyText(String preliminaryReplyText)
Set the text of the completion reply sent before data transfer
|
clearInvocations, getInvocation, handleCommand, numberOfInvocations, sendReply
assertValidReplyCode, getReplyTextBundle, quotes, setReplyTextBundle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleCommand
protected int preliminaryReplyCode
protected String preliminaryReplyText
protected String preliminaryReplyMessageKey
protected int finalReplyCode
protected String finalReplyText
protected String finalReplyMessageKey
protected AbstractStubDataCommandHandler()
public final void handleCommand(Command command, Session session, InvocationRecord invocationRecord) throws Exception
beforeProcessData()
methodprocessData()
methodafterProcessData()
methodhandleCommand
in class AbstractTrackingCommandHandler
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateException
- - if an error occursAbstractTrackingCommandHandler.handleCommand(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session, org.mockftpserver.core.command.InvocationRecord)
protected void sendFinalReply(Session session)
session
- - the Sessionprotected void beforeProcessData(Command command, Session session, InvocationRecord invocationRecord) throws Exception
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateException
- - if an error occursprotected abstract void processData(Command command, Session session, InvocationRecord invocationRecord) throws Exception
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateException
- - if an error occursprotected void afterProcessData(Command command, Session session, InvocationRecord invocationRecord) throws Exception
command
- - the Command to be handledsession
- - the session on which the Command was submittedinvocationRecord
- - the InvocationRecord; CommandHandlers are expected to add
handler-specific data to the InvocationRecord, as appropriateException
- - if an error occurspublic void setFinalReplyCode(int finalReplyCode)
finalReplyCode
- - the final reply codeAssertFailedException
- - if the finalReplyCode is invalidpublic void setFinalReplyMessageKey(String finalReplyMessageKey)
finalReplyMessageKey
- - the final reply message keypublic void setFinalReplyText(String finalReplyText)
finalReplyText
- - the final reply textpublic void setPreliminaryReplyCode(int preliminaryReplyCode)
preliminaryReplyCode
- - the preliminary reply code to setAssertFailedException
- - if the preliminaryReplyCode is invalidpublic void setPreliminaryReplyMessageKey(String preliminaryReplyMessageKey)
preliminaryReplyMessageKey
- - the preliminary reply message keypublic void setPreliminaryReplyText(String preliminaryReplyText)
preliminaryReplyText
- - the preliminary reply textCopyright © 2016. All rights reserved.