org.bibalex.daf.handlers.filehandler
Class FTPThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.bibalex.daf.handlers.filehandler.FTPThread
All Implemented Interfaces:
java.lang.Runnable

 class FTPThread
extends java.lang.Thread

This class represents a FTP Thread instance that can be used to get, put or delete a single file.

Author:
Fadi.Edward

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean bAssigned
           
private  com.enterprisedt.net.ftp.FTPClient ftpClient
           
private  java.lang.String localFilePath
           
private  FileHandlerObservable observable
          The Observable to use to notify successfull operation.
private  int operation
           
private  java.lang.String remoteFilePath
           
private  FTPThreadsPool threadsPool
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FTPThread(com.enterprisedt.net.ftp.FTPClient ftpClient, FTPThreadsPool threadsPool)
          Constructor
FTPThread(com.enterprisedt.net.ftp.FTPClient ftpClient, FTPThreadsPool threadsPool, FileHandlerObservable observable)
          Constructor
 
Method Summary
 void AssignDelete(java.lang.String remoteFilePath)
          Prepares the thread for executing a delete operation.
 void AssignGet(java.lang.String localFilePath, java.lang.String remoteFilePath)
          Prepares the thread for executing a get operation.
 void AssignPut(java.lang.String localFilePath, java.lang.String remoteFilePath)
          Prepares the thread for executing a put operation.
 void finalize()
          Finalizes the FTPThread by quiting the ftp connection.
protected static void notifyObservers(FileHandlerObservable observable, java.lang.String localFilePath, java.lang.String remoteFilePath, FileHandlerObservedObject.FileHandlerOperation operation)
          Synchronized method to notify the observers.
 void run()
          Thread Run Method.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

localFilePath

private java.lang.String localFilePath

remoteFilePath

private java.lang.String remoteFilePath

ftpClient

private com.enterprisedt.net.ftp.FTPClient ftpClient

threadsPool

private FTPThreadsPool threadsPool

operation

private int operation

bAssigned

private boolean bAssigned

observable

private FileHandlerObservable observable
The Observable to use to notify successfull operation.

Constructor Detail

FTPThread

FTPThread(com.enterprisedt.net.ftp.FTPClient ftpClient,
          FTPThreadsPool threadsPool)
Constructor

Parameters:
ftpClient - The client to be used in this thread.
threadsPool - The Threads pool this FTPThread is part of.

FTPThread

FTPThread(com.enterprisedt.net.ftp.FTPClient ftpClient,
          FTPThreadsPool threadsPool,
          FileHandlerObservable observable)
Constructor

Parameters:
ftpClient - The client to be used in this thread.
threadsPool - The Threads pool this FTPThread is part of.
observable - The Observable used to notify operations
Method Detail

finalize

public void finalize()
Finalizes the FTPThread by quiting the ftp connection.

Overrides:
finalize in class java.lang.Object
See Also:
Object.finalize()

AssignGet

public void AssignGet(java.lang.String localFilePath,
                      java.lang.String remoteFilePath)
Prepares the thread for executing a get operation.

Parameters:
localFilePath - The destination path on the local machine.
remoteFilePath - The source path on the server.

AssignPut

public void AssignPut(java.lang.String localFilePath,
                      java.lang.String remoteFilePath)
Prepares the thread for executing a put operation.

Parameters:
localFilePath - The source path on the local machine.
remoteFilePath - The destination path on the server.

AssignDelete

public void AssignDelete(java.lang.String remoteFilePath)
Prepares the thread for executing a delete operation.

Parameters:
remoteFilePath - The path of the file to be deleted on the server.

run

public void run()
Thread Run Method. Called indirectly through Thread.Start();

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

notifyObservers

protected static void notifyObservers(FileHandlerObservable observable,
                                      java.lang.String localFilePath,
                                      java.lang.String remoteFilePath,
                                      FileHandlerObservedObject.FileHandlerOperation operation)
Synchronized method to notify the observers. This method was implemented as suynchronized as some items notifications are neglected due to multithreading.

Parameters:
observable - The observable object to use in the notifications.
localFilePath - local file name (null if remote only operation).
remoteFilePath - remote file name (null if local only operation).
operation - the applied operation.