|
Secure FTP Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SftpListener
The event listener abstraction. Implements methods for capturing events sourced from Sftp class.
Typicaly your application will implement this interface to capture the following events :SftpConnectedEvent
SftpDisconnectedEvent
SftpUploadEvent
SftpDownloadEvent
SftpListingEvent
SftpProgressEvent
SftpDeleteDirEvent
SftpDeleteFileEvent
SftpRenameFileEvent
SftpCreateDirEvent
SftpChangeDirEvent
In addition to implementing this interface your application should register itself as an EventListener which may look somewhat like this:
import com.jscape.inet.sftp.*; import com.jscape.inet.sftp.events.*; import com.jscape.inet.ssh.util.SshParameters; public class MySftpListener implements SftpListener { public void connected(SftpConnectedEvent event) { System.out.println("Connected to host: " + event.getHostname()); } public void disconnected(SftpDisconnectedEvent event) { System.out.println("Disconnected from host: " + event.getHostname()); } public void download(SftpDownloadEvent event) { // process event } public void upload(SftpUploadEvent event) { // process event } public void progress(SftpProgressEvent event) { // process event } public void dirListing(SftpListingEvent event) { // process event } public void deleteDir(SftpDeleteDirEvent event) { // process event } public void deleteFile(SftpDeleteFileEvent event) { // process event } public void renameFile(SftpRenameFileEvent event) { // process event } public void createDir(SftpCreateDirEvent event) { // process event } public void changeDir(SftpChangeDirEvent event) { // process event } public static void main(String[] args) { try { String hostname = "ftp.host.com"; String username = "jsmith"; String password = "secret"; // create connection parameters SshParameters sshParams = new SshParameters(hostname, username, password); Sftp sftp = new Sftp(sshParams); // subscribe listener to published events sftp.addSftpListener(new MySftpListener()); // connect then disconnect sftp.connect(); sftp.disconnect(); } catch (SftpException e) { e.printStackTrace(); } } }
Method Summary | |
---|---|
void |
changeDir(SftpChangeDirEvent event)
Invoked when the remote directory path is changed. |
void |
connected(SftpConnectedEvent event)
Invoked when connection to server is established. |
void |
createDir(SftpCreateDirEvent event)
Invoked when a directory is created. |
void |
deleteDir(SftpDeleteDirEvent event)
Invoked when directory is deleted. |
void |
deleteFile(SftpDeleteFileEvent event)
Invoked when a file is deleted. |
void |
dirListing(SftpListingEvent event)
Invoked when directory listing is retrieved from server. |
void |
disconnected(SftpDisconnectedEvent event)
Invoked when connection to server is released. |
void |
download(SftpDownloadEvent event)
Invoked when file is downloaded from server. |
void |
progress(SftpProgressEvent event)
Invoked to mark progress of a download or upload operation. |
void |
renameFile(SftpRenameFileEvent event)
Invoked when a file is renamed. |
void |
upload(SftpUploadEvent event)
Invoked when file is uploaded to server. |
Method Detail |
---|
void connected(SftpConnectedEvent event)
event
- a SftpConnectedEvent
SftpConnectedEvent
void disconnected(SftpDisconnectedEvent event)
event
- a SftpDisconnectedEvent
SftpDisconnectedEvent
void download(SftpDownloadEvent event)
event
- a SftpDownloadEvent
SftpDownloadEvent
void upload(SftpUploadEvent event)
event
- a SftpUploadEvent
SftpUploadEvent
void progress(SftpProgressEvent event)
event
- a SftpProgressEvent
SftpProgressEvent
void dirListing(SftpListingEvent event)
event
- a SftpListingEvent
SftpListingEvent
void deleteDir(SftpDeleteDirEvent event)
event
- a SftpDeleteDirEvent
SftpDeleteDirEvent
void deleteFile(SftpDeleteFileEvent event)
event
- a SftpDeleteFileEvent
SftpDeleteFileEvent
void renameFile(SftpRenameFileEvent event)
event
- a SftpRenameFileEvent
SftpRenameFileEvent
void createDir(SftpCreateDirEvent event)
event
- a SftpCreateDirEvent
SftpCreateDirEvent
void changeDir(SftpChangeDirEvent event)
event
- a SftpChangeDirEvent
SftpChangeDirEvent
|
Secure FTP Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |