|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bibalex.daf.handlers.filehandler.FTPThreadsPool
class FTPThreadsPool
A pool of FTP Threads, maintaining a fixed number of connections to the server an reducing the cost of recreating threads. This class is a Singlton (Only one instance can be instantiated).
Field Summary | |
---|---|
private static FTPThreadsPool |
currentInstance
|
private java.util.Hashtable<java.lang.String,FTPThread> |
freeThreads
|
private java.lang.String |
hostName
|
private FileHandlerObservable |
observable
|
private java.lang.String |
password
|
private int |
poolSize
|
private java.util.Hashtable<java.lang.String,FTPThread> |
usedThreads
|
private java.lang.String |
userName
|
Constructor Summary | |
---|---|
private |
FTPThreadsPool(java.lang.String hostName,
java.lang.String userName,
java.lang.String password,
int poolSize)
Private Constructor, preventing any external instantiation of new objects. |
private |
FTPThreadsPool(java.lang.String hostName,
java.lang.String userName,
java.lang.String password,
int poolSize,
FileHandlerObservable observable)
Private Constructor, preventing any external instantiation of new objects. |
Method Summary | |
---|---|
private FTPThread |
createThread()
Create a new Thread. |
void |
finalize()
Releases all used threads. |
(package private) FTPThread |
getThread()
Retreives a thread, if there exists free threads one of them is returned, if not and the pool size wasn't reached a new thread is created, elsewise this method sends a wait() signal and halts. |
static FTPThreadsPool |
getThreadsPool(java.lang.String hostName,
java.lang.String userName,
java.lang.String password,
int poolSize)
Implementing a Singleton pattern in retrieving the instance of the Class. |
static FTPThreadsPool |
getThreadsPool(java.lang.String hostName,
java.lang.String userName,
java.lang.String password,
int poolSize,
FileHandlerObservable observable)
Implementing a Singleton pattern in retrieving the instance of the Class. |
void |
releaseThread(FTPThread threadCopier)
Release a thread to be returned to the Free Threads Hash. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String hostName
private java.lang.String userName
private java.lang.String password
private int poolSize
private java.util.Hashtable<java.lang.String,FTPThread> usedThreads
private java.util.Hashtable<java.lang.String,FTPThread> freeThreads
private static FTPThreadsPool currentInstance
private FileHandlerObservable observable
Constructor Detail |
---|
private FTPThreadsPool(java.lang.String hostName, java.lang.String userName, java.lang.String password, int poolSize)
hostName
- Host Network Name or IP.userName
- User Name.password
- Password.poolSize
- Pool Size.private FTPThreadsPool(java.lang.String hostName, java.lang.String userName, java.lang.String password, int poolSize, FileHandlerObservable observable)
hostName
- Host Network Name or IP.userName
- User Name.password
- Password.poolSize
- Pool Size.observable
- FileHandlerObservable object to be assigned to the threadsMethod Detail |
---|
public static FTPThreadsPool getThreadsPool(java.lang.String hostName, java.lang.String userName, java.lang.String password, int poolSize)
hostName
- Host Network Name or IP.userName
- User Name.password
- Password.poolSize
- Pool Size.
public static FTPThreadsPool getThreadsPool(java.lang.String hostName, java.lang.String userName, java.lang.String password, int poolSize, FileHandlerObservable observable)
hostName
- Host Network Name or IP.userName
- User Name.password
- Password.poolSize
- Pool Size.observable
- FileHandlerObservable object to be assigned to the threads
public void finalize()
finalize
in class java.lang.Object
public void releaseThread(FTPThread threadCopier)
threadCopier
- The thread to be freed.private FTPThread createThread()
FTPThread getThread()
FTPThread
instance.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |