Package org.apache.ftpserver.ftplet
Class DefaultFtplet
java.lang.Object
org.apache.ftpserver.ftplet.DefaultFtplet
- All Implemented Interfaces:
Ftplet
Default ftplet implementation. All the callback method returns null. It is
just an empty implementation. You can derive your ftplet implementation from
this class.
- Author:
- Apache MINA Project
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionafterCommand(FtpSession session, FtpRequest request, FtpReply reply) Called by the ftplet container after a command has been executed by the server.beforeCommand(FtpSession session, FtpRequest request) Called by the ftplet container before a command is executed by the server.voiddestroy()Called by the Ftplet container to indicate to a ftplet that the ftplet is being taken out of service.voidinit(FtpletContext ftpletContext) Called by the ftplet container to indicate to a ftplet that the ftplet is being placed into service.onAppendEnd(FtpSession session, FtpRequest request) Override this method to intercept file appends after completiononAppendStart(FtpSession session, FtpRequest request) Override this method to intercept file appendsonConnect(FtpSession session) Client connect notification method.onDeleteEnd(FtpSession session, FtpRequest request) Override this method to handle deletions after completiononDeleteStart(FtpSession session, FtpRequest request) Override this method to intercept deletionsonDisconnect(FtpSession session) Client disconnect notification method.onDownloadEnd(FtpSession session, FtpRequest request) Override this method to handle downloads after completiononDownloadStart(FtpSession session, FtpRequest request) Override this method to intercept downloadsonLogin(FtpSession session, FtpRequest request) Override this method to intercept user loginsonMkdirEnd(FtpSession session, FtpRequest request) Override this method to handle creation of directories after completiononMkdirStart(FtpSession session, FtpRequest request) Override this method to intercept creation of directoriesonRenameEnd(FtpSession session, FtpRequest request) Override this method to handle renames after completiononRenameStart(FtpSession session, FtpRequest request) Override this method to intercept renamesonRmdirEnd(FtpSession session, FtpRequest request) Override this method to handle deletion of directories after completiononRmdirStart(FtpSession session, FtpRequest request) Override this method to intercept deletion of directoriesonSite(FtpSession session, FtpRequest request) Override this method to intercept SITE commandsonUploadEnd(FtpSession session, FtpRequest request) Override this method to handle uploads after completiononUploadStart(FtpSession session, FtpRequest request) Override this method to intercept uploadsonUploadUniqueEnd(FtpSession session, FtpRequest request) Override this method to handle unique uploads after completiononUploadUniqueStart(FtpSession session, FtpRequest request) Override this method to intercept unique uploads
-
Constructor Details
-
DefaultFtplet
public DefaultFtplet()A default constructor that does nothing
-
-
Method Details
-
init
Called by the ftplet container to indicate to a ftplet that the ftplet is being placed into service. The ftplet container calls the init method exactly once after instantiating the ftplet. The init method must complete successfully before the ftplet can receive any requests.- Specified by:
initin interfaceFtplet- Parameters:
ftpletContext- The currentFtpletContext- Throws:
FtpException- If the initialization failed
-
destroy
public void destroy()Called by the Ftplet container to indicate to a ftplet that the ftplet is being taken out of service. This method is only called once all threads within the ftplet's service method have exited. After the ftplet container calls this method, callback methods will not be executed. If the ftplet initialization method fails, this method will not be called. -
onConnect
Client connect notification method.- Specified by:
onConnectin interfaceFtplet- Parameters:
session- The currentFtpSession- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDisconnect
Client disconnect notification method. This is the last callback method.- Specified by:
onDisconnectin interfaceFtplet- Parameters:
session- The currentFtpSession- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
beforeCommand
public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException Called by the ftplet container before a command is executed by the server. The implementation should return based on the desired action to be taken by the server:FtpletResult.DEFAULT: The server continues as normal and executes the commandFtpletResult.NO_FTPLET: The server does not call any more Ftplets before this command but continues execution of the command as usualFtpletResult.SKIP: The server skips over execution of the command. Note that the Ftplet is responsible for returning the appropriate reply to the client, or the client might deadlock.FtpletResult.DISCONNECT: The server will immediately disconnect the client.- Ftplet throws exception: Same as
FtpletResult.DISCONNECT
- Specified by:
beforeCommandin interfaceFtplet- Parameters:
session- The current sessionrequest- The current request- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
afterCommand
public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply) throws FtpException, IOException Called by the ftplet container after a command has been executed by the server. The implementation should return based on the desired action to be taken by the server:FtpletResult.DEFAULT: The server continues as normalFtpletResult.NO_FTPLET: The server does not call any more Ftplets before this command but continues as normalFtpletResult.SKIP: Same asFtpletResult.DEFAULTFtpletResult.DISCONNECT: The server will immediately disconnect the client.- Ftplet throws exception: Same as
FtpletResult.DISCONNECT
- Specified by:
afterCommandin interfaceFtplet- Parameters:
session- The current sessionrequest- The current requestreply- the reply that was sent for this command. Implementations can use this to check the reply code and thus determine if the command was successfully processed or not.- Returns:
- The desired action to be performed by the server
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onLogin
public FtpletResult onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept user logins- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDeleteStart
public FtpletResult onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept deletions- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDeleteEnd
public FtpletResult onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle deletions after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onUploadStart
public FtpletResult onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept uploads- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onUploadEnd
public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle uploads after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDownloadStart
public FtpletResult onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept downloads- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onDownloadEnd
public FtpletResult onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle downloads after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onRmdirStart
public FtpletResult onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept deletion of directories- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onRmdirEnd
public FtpletResult onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle deletion of directories after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onMkdirStart
public FtpletResult onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept creation of directories- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onMkdirEnd
public FtpletResult onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle creation of directories after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onAppendStart
public FtpletResult onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept file appends- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onAppendEnd
public FtpletResult onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept file appends after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onUploadUniqueStart
public FtpletResult onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept unique uploads- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onUploadUniqueEnd
public FtpletResult onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle unique uploads after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onRenameStart
public FtpletResult onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to intercept renames- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onRenameEnd
public FtpletResult onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException Override this method to handle renames after completion- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-
onSite
Override this method to intercept SITE commands- Parameters:
session- The currentFtpSessionrequest- The currentFtpRequest- Returns:
- The action for the container to take
- Throws:
FtpException- If a FTP error occurredIOException- If an IO error occurred
-