|
Secure FTP Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
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 :SftpConnectedEventSftpDisconnectedEventSftpUploadEventSftpDownloadEventSftpListingEventSftpProgressEventSftpDeleteDirEventSftpDeleteFileEventSftpRenameFileEventSftpCreateDirEventSftpChangeDirEventIn 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 |
public void connected(SftpConnectedEvent event)
event - a SftpConnectedEventSftpConnectedEventpublic void disconnected(SftpDisconnectedEvent event)
event - a SftpDisconnectedEventSftpDisconnectedEventpublic void download(SftpDownloadEvent event)
event - a SftpDownloadEventSftpDownloadEventpublic void upload(SftpUploadEvent event)
event - a SftpUploadEventSftpUploadEventpublic void progress(SftpProgressEvent event)
event - a SftpProgressEventSftpProgressEventpublic void dirListing(SftpListingEvent event)
event - a SftpListingEventSftpListingEventpublic void deleteDir(SftpDeleteDirEvent event)
event - a SftpDeleteDirEventSftpDeleteDirEventpublic void deleteFile(SftpDeleteFileEvent event)
event - a SftpDeleteFileEventSftpDeleteFileEventpublic void renameFile(SftpRenameFileEvent event)
event - a SftpRenameFileEventSftpRenameFileEventpublic void createDir(SftpCreateDirEvent event)
event - a SftpCreateDirEventSftpCreateDirEventpublic void changeDir(SftpChangeDirEvent event)
event - a SftpChangeDirEventSftpChangeDirEvent
|
Secure FTP Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||