Secure FTP Factory

com.jscape.inet.sftp.events
Interface SftpListener

All Known Implementing Classes:
SftpAdapter

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

connected

public void connected(SftpConnectedEvent event)
Invoked when connection to server is established.

Parameters:
event - a SftpConnectedEvent
See Also:
SftpConnectedEvent

disconnected

public void disconnected(SftpDisconnectedEvent event)
Invoked when connection to server is released.

Parameters:
event - a SftpDisconnectedEvent
See Also:
SftpDisconnectedEvent

download

public void download(SftpDownloadEvent event)
Invoked when file is downloaded from server.

Parameters:
event - a SftpDownloadEvent
See Also:
SftpDownloadEvent

upload

public void upload(SftpUploadEvent event)
Invoked when file is uploaded to server.

Parameters:
event - a SftpUploadEvent
See Also:
SftpUploadEvent

progress

public void progress(SftpProgressEvent event)
Invoked to mark progress of a download or upload operation.

Parameters:
event - a SftpProgressEvent
See Also:
SftpProgressEvent

dirListing

public void dirListing(SftpListingEvent event)
Invoked when directory listing is retrieved from server.

Parameters:
event - a SftpListingEvent
See Also:
SftpListingEvent

deleteDir

public void deleteDir(SftpDeleteDirEvent event)
Invoked when directory is deleted.

Parameters:
event - a SftpDeleteDirEvent
See Also:
SftpDeleteDirEvent

deleteFile

public void deleteFile(SftpDeleteFileEvent event)
Invoked when a file is deleted.

Parameters:
event - a SftpDeleteFileEvent
See Also:
SftpDeleteFileEvent

renameFile

public void renameFile(SftpRenameFileEvent event)
Invoked when a file is renamed.

Parameters:
event - a SftpRenameFileEvent
See Also:
SftpRenameFileEvent

createDir

public void createDir(SftpCreateDirEvent event)
Invoked when a directory is created.

Parameters:
event - a SftpCreateDirEvent
See Also:
SftpCreateDirEvent

changeDir

public void changeDir(SftpChangeDirEvent event)
Invoked when the remote directory path is changed.

Parameters:
event - a SftpChangeDirEvent
See Also:
SftpChangeDirEvent

Secure FTP Factory

Copyright JSCAPE 1999-2007 All Rights Reserved