org.bibalex.daf.handlers.filehandler
Class FTPClientsPool

java.lang.Object
  extended by org.bibalex.daf.handlers.filehandler.FTPClientsPool

 class FTPClientsPool
extends java.lang.Object

This class represents a pool of FTP clients, used to limit the number of FTPClients created while maintaning multithreading algorithm


Field Summary
private  java.util.Hashtable<java.lang.String,com.enterprisedt.net.ftp.FTPClient> freeFTPClients
           
private  java.lang.String hostName
           
private  java.util.Hashtable<java.lang.String,com.enterprisedt.net.ftp.FTPClient> inUseFTPClients
           
private  java.lang.String password
           
private  int poolSize
           
private  java.lang.String userName
           
 
Constructor Summary
FTPClientsPool(java.lang.String hostName, java.lang.String userName, java.lang.String password, int poolSize)
          Constructor
 
Method Summary
private  com.enterprisedt.net.ftp.FTPClient createFTPClient()
          Creates a new Object of the FTPClient, addressed privatly, when the pool is still empty
(package private)  com.enterprisedt.net.ftp.FTPClient getFTPClient()
          Retives an existing instance of FTPClient, if there is a free one it is returned, if there is no and the pool size was not reached it creates a new one, If the pool is full and non is free it sends a wait signal
(package private)  void releaseFTPClient(com.enterprisedt.net.ftp.FTPClient ftpClient)
          This method indicates that a specific FTPClient is no longer in use, It is then moved from the used Clients Hash to the free Clients Hash
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostName

private java.lang.String hostName

userName

private java.lang.String userName

password

private java.lang.String password

poolSize

private int poolSize

inUseFTPClients

private java.util.Hashtable<java.lang.String,com.enterprisedt.net.ftp.FTPClient> inUseFTPClients

freeFTPClients

private java.util.Hashtable<java.lang.String,com.enterprisedt.net.ftp.FTPClient> freeFTPClients
Constructor Detail

FTPClientsPool

FTPClientsPool(java.lang.String hostName,
               java.lang.String userName,
               java.lang.String password,
               int poolSize)
Constructor

Parameters:
hostName - The Host Network Name or IP
userName - The User Name for the Connection
password - The Password for the Connection
poolSize - The Pool Size of the FTPClients
Method Detail

createFTPClient

private com.enterprisedt.net.ftp.FTPClient createFTPClient()
Creates a new Object of the FTPClient, addressed privatly, when the pool is still empty

Returns:
a instance of FTPClient

getFTPClient

com.enterprisedt.net.ftp.FTPClient getFTPClient()
Retives an existing instance of FTPClient, if there is a free one it is returned, if there is no and the pool size was not reached it creates a new one, If the pool is full and non is free it sends a wait signal

Returns:
an FTPClient instance free.

releaseFTPClient

void releaseFTPClient(com.enterprisedt.net.ftp.FTPClient ftpClient)
This method indicates that a specific FTPClient is no longer in use, It is then moved from the used Clients Hash to the free Clients Hash

Parameters:
ftpClient - The FTPClient to be released